I\'ve created a TimePicker in layout and I want it to show time with format 24h.
Can you help me? Thanks.
I need the same just for an application to set the duration spend for doing a task. I found that I just need to extend the TimePickerDialog class and pass True in the last constructor parameter boolean is24HourView.
public class DurationPickerDialog extends TimePickerDialog {
public DurationPickerDialog(Context context, TimePickerDialog.OnTimeSetListener callBack, int hourOfDay, int minute){
super(context, callBack, hourOfDay, minute, true);
}
Then you only need to create this as
TimePickerDialog durationPicker = new DurationPickerDialog(getActivity(), this, hour, minute);
durationPicker.setTitle("Duration:");