2011年9月28日 星期三

About DIII Game Guide App Change Locale

主畫面按menu 可以選擇語系


private void changeLang(int whichcountry) {
String[] items = new String[] { "Deutsch", "English(United States)",
"Español(España)", "Français", "Русский", "한국어", "中文(繁體)",
"中文(简体)" };

Resources res = getResources();
Locale.setDefault(getLocale(whichcountry));
Configuration config = new Configuration();
config.locale = Locale.getDefault();
res.updateConfiguration(config, res.getDisplayMetrics());
updateView();
}


private Locale getLocale(int whichcountry) {
switch (whichcountry) {
case 0:
return Locale.GERMANY;
case 1:
return Locale.US;
case 2:
return new Locale("es");
case 3:
return Locale.FRANCE;
case 4:
return new Locale("ru");
case 5:
return Locale.KOREA;
case 6:
return Locale.TRADITIONAL_CHINESE;
case 7:
return Locale.SIMPLIFIED_CHINESE;
default:
return Locale.ENGLISH;
}
}

沒有留言:

張貼留言