Reputation: 4570
In my app I have editText
, clicking on it calls openDatePicker()
function.
protected void openDatePicker() {
DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
GregorianCalendar calendar = new GregorianCalendar();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, monthOfYear);
calendar.set(Calendar.DATE, dayOfMonth);
Date birthDate = calendar.getTime();
setDate(birthDate);
}
};
DatePickerDialog dialog = prepareDatePickerDialg(mDateSetListener);
dialog.show();
}
I must set max value when user will choose date. So can anybody suggest me something? thanks
Upvotes: 0
Views: 598
Reputation: 45503
As per earlier comment:
If you're targeting API level 11 and up, you can get the DatePicker
instance from the dialog and call setMaxDate(long)
on it. For older devices, an alternative is to use a backported version, like this one (although it has some drawbacks too).
Upvotes: 1