android-如何设置格式为24h的TimePicker显示
我已经在布局中创建了一个TimePicker,我希望它以24h格式显示时间。
你能帮助我吗? 谢谢。
mum asked 2020-07-06T14:08:42Z
10个解决方案
74 votes
setIs24HourView(true)是用于选择24小时或AM / PM模式下的一天中的时间的视图。您可以将setIs24HourView(true)方法与TimePicker结合使用。
VendettaDroid answered 2020-07-06T14:09:01Z
38 votes
默认将picker.setIs24HourView(DateFormat.is24HourFormat(this));设置为24小时模式并不总是一个好主意,因为许多国家/地区使用不同的约定。 对于这种情况,请使用DateFormat.is24HourFormat(getActivity())。
您的最终代码可能看起来像picker.setIs24HourView(DateFormat.is24HourFormat(this));。
更多详细信息,请参见:
[HTTP://developer.Android.com/贵的/topics/UI/controls/pickers.HTML]
[HTTP://developer.Android.com/reference/Android/widget/time picker.HTML]
[HTTP://developer.Android.com/reference/Android/text/format/date format.HTML]
BREMI answered 2020-07-06T14:09:43Z
20 votes
<