timepicker:当选择24或AM / PM模式 [英] timepicker: when to choose 24 or am/pm modes

查看:190
本文介绍了timepicker:当选择24或AM / PM模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序的几个timepickers。

I have a few timepickers in my app.

在我的国家(西班牙),我们是用来显示时间在24小时内模式......但在其他国家被用来AM / PM。

In my country (Spain) we are used to displaying time in 24 hours mode... but in other countries are used to am/pm.

我知道如何设置一个Timepicker 24或AM / PM模式... 但是,什么是显示AM / PM或24取决于设备的区域或国家的最好的方法?我怎么能知道,选择一种或另一种方式?

I know how to set a Timepicker to 24 or am/pm mode... But what is the best approach to show am/pm or 24 depending of the device locale or country? How can I know to select one or another mode?

非常感谢你。

(对不起,我的英文不好)

(Sorry for my poor english)

推荐答案

有几种方法可以做到这一点,其中第一个是刚刚使用该设备的设置,从而让用户做出这个决定,但要注意,可以在某些情况下,因此不可靠;

There are several ways to do this, of which the first is to just use the device settings and thus let the user make this decision, but be aware that this can return a null value in some cases and is therefore not as reliable;

String clockType = android.provider.Settings.System.getString(context.getContentResolver(), android.provider.Settings.System.TIME_12_24);

更好的解决方案由wonder.mice,这是使用给定的:

A better solution is given by wonder.mice, which is using:

boolean is24HourFormat = DateFormat.is24HourFormat();

也请参考相关页:<一href="http://developer.android.com/reference/android/text/format/DateFormat.html#is24HourFormat(android.content.Context)">http://developer.android.com/reference/android/text/format/DateFormat.html#is24HourFormat(android.content.Context)

这篇关于timepicker:当选择24或AM / PM模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆