0

I want to disable the past dates of date picker in android. i can do it by using

dialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);

This is working fine and the past dates in date picker looks disabled. But I can still click on a previous date and select it. How to not let that happen ? below is the screenshot of my date picker

enter image description here

Abhishek Patel
  • 4,280
  • 1
  • 24
  • 38
  • add a if condition to check whether the date selected is before current date.if True,then show a toast saying "invalid date". – Rushi Ayyappa Nov 17 '16 at 04:08
  • duplicate of http://stackoverflow.com/questions/32796326/still-able-to-select-disabled-dates-in-date-picker/34542301#34542301 – sasikumar Nov 17 '16 at 04:33

1 Answers1

0

you can get the calendarInstance and setMinDate to current time

Calendar newCalendar = Calendar.getInstance();
newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH),   newCalendar.get(Calendar.DAY_OF_MONTH));
    mDatePickerDialog.getDatePicker().setMinDate(newCalendar.getTimeInMillis());
Anirudh Goud
  • 346
  • 2
  • 11