我正在寻找一种方法来“交换”默认语言与主项目中string.xml文件已经定义的辅助语言。这只会影响特定的风味。

示例情况:与所有其他样式相比,应用程序的样式针对的区域不同,在该区域中默认语言不再对用户有意义。

注意:从主项目复制粘贴字符串文件不是解决方案。

最佳答案

也许你可以尝试

public void setLocale(String lang) {
    myLocale = new Locale(lang);
    Resources res = getResources();
    DisplayMetrics dm = res.getDisplayMetrics();
    Configuration conf = res.getConfiguration();
    conf.locale = myLocale;
    res.updateConfiguration(conf, dm);
    reloadUI(); // you may not need this, in my activity ui must be refreshed immediately so it has a function like this.
}


here

07-24 09:49
查看更多