I have a button, on click on the which the time format of a TimePickerDialog should change from 12 hours to 24 hours and vice versa.
I know I have to use onPrepareDialog(), but how can I change the time format inside onPrepareDialog ?
Any help is appreciated!
Thank you.
Finally did a work around to achieve this!.
Instead of using onPrepareDialog(),
I used a variable to keep tack of whether time should be shown in 24hrs or 12hrs format.
which will be set to true when 24 hrs is selected by user, else false.
I added 2 constants
both for 12 hours and 24 hours format.
In touch listener, it calls showDialog().
which are handled in switch cases of onCreateDialog() by creating new object for
TimePickerDialog, with true or false as the last parameter of constructor which opens the timpicker with corresponding time formats. 🙂