将默认区域设置为 DatePicker 和 TimePicker [英] Set default Locale to DatePicker and TimePicker

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

问题描述

我在自定义 Dialog 中使用了 DatePickerTimePicker.该功能运行良好,但是当我更改应用程序的默认 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.

问题在于 DatePickerTimePicker 并未在所有 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.

我想一直将 DatePickerTimePicker 的本地化更改为英语,或者在 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.

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

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