I have a setting in my app that allows user to select different localization (language), ie Chinese, German, etc
.
What i would like to do is that once the user makes their choice, to immediately update the layout with strings in the currently selected language. Of course, i want the lang change propagated to ALL current activities, without reloading the app.
I found this (havent tried yet), but was wondering if there is a cleaner way of doing it.
http://www.tutorialforandroid.com/2009/01/force-localize-application-on-android.html
Gracias
I also had this issue.I used the code below and then it changed the language without refreshing the activity
public void setLocale(String lang) {
myLocale = new Locale(lang);
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
onConfigurationChanged(conf);
/*Intent refresh = new Intent(this, AndroidLocalize.class);
startActivity(refresh);*/
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
// refresh your views here
lblLang.setText(R.string.langselection);
super.onConfigurationChanged(newConfig);
}
I hope it would help you.......
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With