google calender library disable Previous date

191 views Asked by At

Hi i am using this library for implementing date selection. Can some please explain how do i set minimum date on this(Disable previous dates from selecting)

   final DatePickerDialog datePickerDialog = DatePickerDialog.newInstance(new OnDateSetListener() {

                public void onDateSet(DatePickerDialog datePickerDialog, int year, int month, int day) {

                    tvDisplayDate.setText(
                            new StringBuilder().append(pad(day))
                            .append(" ").append(pad(month+1)).append(" ").append(pad(year)));
                    tvDisplayDate.setTextColor(getResources().getColor(android.R.color.holo_blue_light));
                }

            }, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));

here i can compare the date but what i need is to prevent user tapping the older dates..This is for a booking application please help

1

There are 1 answers

2
Harry On

Your DatePickerDialog has methods for setting min and max date.

Here is example:

 datePickerDialog.setMinDate(mMinDate);

And then you can show your dialog.