Android 日期选择器、日期范围选择器:MaterialDateRangePicker
Credit to the original amazing material date picker library by wdullaer - https://github.com/wdullaer/MaterialDateTimePicker
Date Picker | Time Picker |
---|---|
步入正题:日期范围选择器 MaterialDateRangePicker
Update
-Added Time Range Picker
Date Selection
Time Selection
Support for Android 4.0 and up.
From the original library documentation -
You may also add the library as an Android Library to your project. All the library files live inlibrary.
Using the Pickers
- Implement anOnDateSetListenerorOnTimeSetListener
- Create a `DatePickerDialogusing the supplied factory
Implement anOnDateSetListener
In order to receive the date set in the picker, you will need to implement theOnDateSetListenerinterfaces. Typically this will be theActivityorFragmentthat creates the Pickers.
or
Implement anOnTimeSetListener
In order to receive the time set in the picker, you will need to implement theOnTimeSetListenerinterfaces. Typically this will be theActivityorFragmentthat creates the Pickers.
//new onDateSet@Overridepublic void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth,int yearEnd, int monthOfYearEnd, int dayOfMonthEnd) {}@Overridepublic void onTimeSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth,int yearEnd, int monthOfYearEnd, int dayOfMonthEnd) { String hourString = hourOfDay < 10 ? "0"+hourOfDay : ""+hourOfDay; String minuteString = minute < 10 ? "0"+minute : ""+minute; String hourStringEnd = hourOfDayEnd < 10 ? "0"+hourOfDayEnd : ""+hourOfDayEnd; String minuteStringEnd = minuteEnd < 10 ? "0"+minuteEnd : ""+minuteEnd; String time = "You picked the following time: From - "+hourString+"h"+minuteString+" To - "+hourStringEnd+"h"+minuteStringEnd; timeTextView.setText(time);}
地址:https://github.com/borax12/MaterialDateRangePicker
更多相关文章
- Android 利用TransitionDrawable 实现两张图片渐变切换
- android创建数据库(SQLite)保存图片示例
- Android APP 设置启动的第一张图片
- 如何为Android Activity设置背景图片?
- android 选择图片(从手机照相机或手机图片)
- Android关于图片处理,更改图片灰度
- 阅读《Android 从入门到精通》(13)——日期选择器
- Android上传图片裁剪功能