我有一个TimePickerDialog与is24Hour设置为false,因为我想present最终用户比较熟悉的12小时格式。当小时,分钟和AM PM指示设置和时间返回我怎么能确定最终用户是否选择上午或下午?
这是我的听众:
私人TimePickerDialog.OnTimeSetListener mTimeSetListener =
新TimePickerDialog.OnTimeSetListener(){
@覆盖
公共无效onTimeSet(TimePicker观点,诠释hourOfDay,
INT分钟){
mHour = hourOfDay;
mMinute =分钟;
// mIsAM =哪里可以得到这个值
}
};
解决方案
在 hourOfDay
将永远是24小时。如果使用 is24HourView
打开的对话框中设置为假
,用户将不必处理24小时格式的时间,但它调用时,Android将其转换成一个24小时时间 onTimeSet()
。
I have a TimePickerDialog with is24Hour set to false since I want to present the end-user with the more familiar 12 hour format. When the hour, minute and AM PM indicator are set and the time is returned how can I identify whether the end-user has selected AM or PM?
This is what I have for the listener:
private TimePickerDialog.OnTimeSetListener mTimeSetListener =
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay,
int minute) {
mHour = hourOfDay;
mMinute = minute;
// mIsAM = WHERE CAN I GET THIS VALUE
}
};
解决方案
The hourOfDay
will always be 24-hour. If you opened the dialog with is24HourView
set to false
, the user will not have to deal with 24-hour formatted times, but Android will convert that to a 24-hour time when it calls onTimeSet()
.
相关推荐
最新文章