Back to project page Custom-Time-Picker-Dialog.
The source code is released under:
GNU General Public License
If you think the Android project Custom-Time-Picker-Dialog listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.zia.customui; //from ww w. j a v a 2s.co m import android.app.TimePickerDialog; import android.content.Context; import android.widget.TimePicker; public class CustomTimePickerDialog extends TimePickerDialog { public static final int TIME_PICKER_INTERVAL = 15; private boolean mEventIgnored = false; public CustomTimePickerDialog(Context context, int theme, OnTimeSetListener callBack, int hourOfDay, int minute, boolean is24HourView) { super(context, theme, callBack, hourOfDay, minute, is24HourView); } public CustomTimePickerDialog(Context context, OnTimeSetListener callBack, int hourOfDay, int minute, boolean is24HourView) { super(context, callBack, hourOfDay, minute, is24HourView); } @Override public void onTimeChanged(TimePicker timePicker, int hourOfDay, int minute) { super.onTimeChanged(timePicker, hourOfDay, minute); if (!mEventIgnored) { minute = getRoundedMinute(minute); mEventIgnored = true; timePicker.setCurrentMinute(minute); mEventIgnored = false; } } private int getRoundedMinute(int minute) { if (minute % TIME_PICKER_INTERVAL != 0) { int minuteFloor = minute - (minute % TIME_PICKER_INTERVAL); minute = minuteFloor + (minute == minuteFloor + 1 ? TIME_PICKER_INTERVAL : 0); if (minute == 60) minute = 0; } return minute; } }