I am Using DatePickerDialog. but not showing setDisabledDays. so how is it possible in kotlin. My required is multiple dates disable and also one max and min range of calendar
fun datepicker(){
val year = calendarNow.get(Calendar.YEAR)
val month = calendarNow.get(Calendar.MONTH)
val day = calendarNow.get(Calendar.DAY_OF_MONTH)
val datePickerDialog = DatePickerDialog(this,
{ view, year, monthOfYear, dayOfMonth ->
//my code
}, year, month, day
)
datePickerDialog.datePicker.setMinDate(milliseconds)
//val days = arrayOf<Calendar>(2023-08-22, 2023-08-12, 2023-08-15) //this is disable dates
//datePickerDialog.setDisabledDays() //this line is not working how to solved this
datePickerDialog.show()
}
You can use this "MaterialDateTimePicker" library, which provides enhanced features including the ability to disable specific dates and Min & Max Years and many more...
Here's how you can use the "MaterialDateTimePicker" library to disable specific dates:
In this example, i'm using the "MaterialDateTimePicker" library to create a date picker dialog. We've set the
disabledDaysarray with specific dates that you want to disable and min max years.Library: MaterialDateTimePicker in case you want to see more about it.