一個Android Material 日期范圍選擇器:MaterialDateRangePicker

一個Android Material 日期范圍選擇器,基于wdullaers MaterialDateTimePicker。

Credit to the original amazing material date picker library by wdullaer - https://github.com/wdullaer/MaterialDateTimePicker

Update

-Added Time Range Picker

Date Selection

FROM TO

Time Selection

FROM TO

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

  1. Implement anOnDateSetListenerorOnTimeSetListener
  2. 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
@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth,int yearEnd, int monthOfYearEnd, int dayOfMonthEnd) {

}

@Override
public 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);

}

項目主頁:http://www.baiduhome.net/lib/view/home/1442324625587

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!