更改语言apk失败



我想更改应用程序的英语语言。我创建了一个字符串.xml和值fr文件,但当我启动应用程序时,它仍然是英文的。当我用FR替换原始字符串时,直接重新编译失败。如何进行

感谢

您已经更新了应用程序的Locale和Configration,下面给出了如何设置应用程序Locale的示例。

private static Context updateResources(Context context, String language) {
Locale locale = new Locale(language);
Locale.setDefault(locale);
Resources res = context.getResources();
Configuration config = new Configuration(res.getConfiguration());
if (Build.VERSION.SDK_INT >= 17) {
config.setLocale(locale);
context = context.createConfigurationContext(config);
} else {
config.locale = locale;
res.updateConfiguration(config, res.getDisplayMetrics());
}
return context;
}

就像在你的情况下,你可以将其设置为-

updateResources(this, "fr")

最新更新