本文介绍了设置默认区域设置的DatePicker和TimePicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是的DatePicker TimePicker 在自定义的对话框。该功能工作正常,但我有一个问题,当我更改默认区域设置应用程序相匹配的阿拉伯语。的

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 未本地化上所有的Andr​​oid版本。它适用于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 英语所有的时间要么改变定位,或者将其更改为当区域设置阿拉伯语匹配阿拉伯语。

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

看到这个链接。它可以帮助你解决你的问题。

You need to create your custom DatePicker or TimePicker.See this link http://stackoverflow.com/a/9220899/3864698. It can help you to solve your problem.

或者你可以使用反射来编辑NumberPicker值,请按照this链接了完整的解决方案。

Or you can use Reflection to edit the NumberPicker values, follow this link for the complete solution.

这篇关于设置默认区域设置的DatePicker和TimePicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 02:07