是否可以限制 Android 应用程序中的语言,即当用户更改语言时,我只需要英语和法语生效。问题是当用户选择荷兰语时,选项菜单名称为英语,但更多(系统生成的菜单选项,如果有更多选项要显示)是荷兰语.我希望更多内容是英文的。
请帮忙
NITZ
您可以在应用程序中以编程方式设置区域设置:
Configuration configuration = context.getResources().getConfiguration();
configuration.locale = new Locale(selectedLanguage);
context.getResources().updateConfiguration(configuration, context.getResources().getDisplayMetrics());
其中 selectedLanguage 是保存语言缩写的变量, context 保存对 Context 的引用。
这些早期的答案进一步讨论了可能的解决方案:
更改设备的语言设置(区域设置) https://stackoverflow.com/questions/2596352/change-language-settings-locale-for-the-device
在应用程序本身内更改区域设置 https://stackoverflow.com/questions/2264874/changing-locale-within-the-app-itself
在 Android 中以编程方式更改语言 https://stackoverflow.com/questions/2900023/change-language-programatically-in-android
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)