我所有的文本都在string.xml
文件中,而这些文件又包含在文件夹values-hi, values-en
中。如何指定区域设置马拉或请让我知道的语言说明符值文件夹设置内容之前获取马拉串支持马拉语言
public void setLanguage(String language) {
Locale locale = new Locale(language);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
Locale.getAvailableLocales();
if (checkForLocaleSupport(locale)) {
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
}
}
public boolean checkLocaleSupport(Locale locale){
Locale[] locs= Locale.getAvailableLocales();
for(Locale l:locs){
if(l.equals(locale)){
return true;
}
}
return false;
}
在我的主要活动IM设置语言setLanguage(“HI”)的onCreate()方法。然后设置内容并使用textView即时做mHeaderText.setText(R.string.my_header);我的头文件是从string.xml中读取的,其值为hi-hi文件夹。但如果我将语言设置为“mr”,则不会从values-mr文件夹中获取字符串。非常感谢您的帮助
尝试回答你的问题,我目前正在读这篇文档http://developer.android.com/reference/java/util/Locale.html – Poutrathor
http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes我发现marathi – Poutrathor
@adi给我的方法checkForLocaleSupport()在上面的代码 – dipali