如何在Android中单击按钮将整个应用程序语言从英语转换为德语



>伙计们...开发应用程序后,我遇到了问题。现在,如果用户选择德语,我们有一个新要求,即更改整个应用程序语言。那么如何处理呢?

使用这个:

Resources res = context.getResources();
// Change locale settings in the app.
DisplayMetrics dm = res.getDisplayMetrics();
android.content.res.Configuration conf = res.getConfiguration();
conf.setLocale(new Locale(language_code.toLowerCase()); // API 17+ only.
// Use conf.locale = new Locale(...) if targeting lower versions
res.updateConfiguration(conf, dm);

有关更多信息,请查看此链接:在安卓中以编程方式更改语言

最新更新