将默认区域设置为 DatePicker 和 TimePicker
我在自定义 Dialog
中使用了 DatePicker
和 TimePicker
.该功能运行良好,但是当我更改应用程序的默认 Locale
以匹配阿拉伯语时遇到问题.
I'm using a DatePicker
and a TimePicker
in a custom Dialog
. The functionality works fine, but I have a problem when I change the default Locale
of the app to match the Arabic language.
问题在于 DatePicker
和 TimePicker
并未在所有 Android 版本上本地化.它适用于 Android 4.2.2 及更高版本.但它不适用于 Android 4.1.2 及更低版本.
The problem is that the DatePicker
and TimePicker
are not localized on all Android versions. It works on Android versions 4.2.2 and higher. But It doesn't work on Android versions 4.1.2 And lower.
我想一直将 DatePicker
和 TimePicker
的本地化更改为英语,或者在 Locale
匹配时将其更改为阿拉伯语阿拉伯语.
I want to either change localization of DatePicker
and TimePicker
to English all the time, Or to change it to Arabic when the Locale
matches the Arabic language.
这是Android 4.2.2及更高版本的对话框(与本地化匹配的正确的)
This is the dialog in Android versions 4.2.2 and higher (the correct one that matches the localization)
这是Android 4.1.2及更低版本中的对话框
And this is the dialog in Android versions 4.1.2 and lower
您需要创建自定义的 DatePicker 或 TimePicker.请参阅此链接 https://stackoverflow.com/a/9220899/3864698.它可以帮助您解决问题.
You need to create your custom DatePicker or TimePicker . See this link https://stackoverflow.com/a/9220899/3864698. It can help you to solve your problem.
或者您可以使用反射来编辑 NumberPicker 值,请按照 此链接获取完整解决方案.
Or you can use Reflection to edit the NumberPicker values, follow this link for the complete solution.