Search code examples
androidtimepickerandroid-timepicker

Select a specific time between set interval into TimePickerDialog


Hey I want to implement time selection functionality in TimePickerDialog. User can select any time between 3PM to 6PM. Other times are not allowed to select. How can I do this functionality?


Solution

  • You could try overriding the onTimeChanged(TimePicker view, int hourOfDay, int minute) method and doing your validation there.

    The other option would be to handle it in the TimePickerDialog.OnTimeSetListener listener but this only occurs after the dialog is closed.