Search code examples
androidandroid-datepicker

Date Picker with cancel option in android


Is it possible to have a date/time picker that has a Cancel/Set options in place of a single Set command. My usecase is that when i click on the date picker and the field is not mandatory, i might want to clear the selected value. My code looks something like this :

private DatePickerDialog datePicker = null;

datePicker = new DatePickerDialog(getContext(), new DateSetListener(), year, monthOfYear, dayOfMonth);

Solution

  • There is an issue with the DatePickerDialog and the TimePickerDialog (Issue #34833). We could use a counter as a work-around to get rid of this issue.