我遇到的问题是,当以编程方式将区域设置设置为阿尔巴尼亚语 (sq-AL) 和黑山语 (sr-ME) 时,区域设置似乎无法被识别,因为它默认返回英语。设置意大利语(it)或西类牙语(es)时没有问题,所以我不确定问题可能是什么。所有 string.xml 的格式均正确且命名正确。这是我用来设置区域设置的代码:
Context context = getBaseContext();
Resources res = context.getResources();
DisplayMetrics metrics = res.getDisplayMetrics();
android.content.res.Configuration conf = res.getConfiguration();
langCode = "sr-ME"; // Hard setting langCode for testing
Locale newLocale = new Locale( langCode ) ;
conf.setLocale( newLocale );
res.updateConfiguration( conf, metrics );
如果有人能提供帮助,我们将不胜感激!
最佳答案
“sr-rME”似乎不存在,因此 android 重置为默认值。以下是 Android 支持的语言的详尽列表,您可能会找到答案: What is the list of supported languages/locales on Android?
关于java - 设置阿尔巴尼亚/黑山语言环境时,它会恢复为默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51422417/