我想在我的应用程序中添加一个 timepickerDialog,它可以增加 15 分钟,并且我想获得所选 AM/PM 的值。
请建议...
对于第一个问题,请参阅此 Stack Overflow 帖子。
对于第二个,您应该首先设置一个侦听器:
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();