如何自定义TimePickerDialog?

时间:2011-05-27 11:03:16

标签: android timepicker

我想在我的应用程序中使用timepickerDialog,可以将分钟增加15分,并且我希望获得所选AM / PM的值。

请建议......

1 个答案:

答案 0 :(得分:2)

有关第一期,请参阅this Stack Overflow post

对于第二个,您应该首先设置一个监听器:

OnTimeSetListener listener = new OnTimeSetListener() {
        public void onTimeSet(TimePicker arg0, int hour, int minute) {
            //whatever you want to do with hour and minute
        }
};

然后显示TimePickerDialog

Calendar cal = Calendar.getInstance();
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
TimePickerDialog dialog = new TimePickerDialog(this, listener, hour, minute, true);
dialog.show();