Android 日期选择器、日期范围选择器:MaterialDateRangePicker

一个Android Material 日期范围选择器,基于wdullaers MaterialDateTimePicker。 

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

Date PickerTime Picker
Date PickerTime Picker

步入正题:日期范围选择器 MaterialDateRangePicker

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);

}

地址:https://github.com/borax12/MaterialDateRangePicker
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值