Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set default Locale to DatePicker and 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.

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.

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.

This is the dialog in Android versions 4.2.2 and higher (the correct one that matches the localization)

Android version 4.2.2 and higher

And this is the dialog in Android versions 4.1.2 and lower

Android versions 4.1.2 and lower

like image 391
Abdallah Alaraby Avatar asked Oct 21 '14 13:10

Abdallah Alaraby


1 Answers

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.

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

like image 125
QArea Avatar answered Nov 11 '22 08:11

QArea