How to disable past dates in MaterialDatePicker?

后端 未结 2 1111
野的像风
野的像风 2021-01-23 09:36
 //Material Date Picker
private val calendar = Calendar.getInstance()
private val constraintsBuilder = CalendarConstraints.Builder().setStart(calendar.timeInMillis)
priv         


        
2条回答
  •  执笔经年
    2021-01-23 10:02

    You can build your own DateValidator or you can just use the DateValidatorPointForward provided by the library.

    Something like:

    //Returns a DateValidator which enables days from {@code point}, in 
    //UTC milliseconds, forward
    CalendarConstraints.DateValidator dateValidator = DateValidatorPointForward.from(yourDate);
    constraintsBuilder.setValidator(dateValidator);
    

提交回复
热议问题