Reputation: 5260
What i tried is as follows
final Locale locale = new Locale("en", "US");
Locale.setDefault(locale);
final Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
i wants to set a particular locale to the whole application and i am doing it at Application class level, but above given lines seems to be not working as when i am changing the Locale language specification from the setting the Date-picker do not have an effect of the application class specified locale and taking the locale from setting language specification.
Upvotes: 1
Views: 137
Reputation: 4784
I'm not sure if it works setting a locale on Application level, since I haven't tried it myself.
A workaround (that I know works) is to create a super activity e.g. MyActivity extends Activity
. Put the code
final Locale locale = new Locale("en", "US");
Locale.setDefault(locale);
final Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
in the onCreate()
method of MyActivity, and let all your activities extend MyActivity instead of Activity.
Upvotes: 1