Freelander / freelander.github.io

My personal blog. Welcome to star or watch.

Home Page:https://gojun.me/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onConfigurationChanged()怎么更新语言?

tracyliu1 opened this issue · comments

Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
res.updateConfiguration(conf, dm);

languageToLoad这个参数是怎么得到的?
config.locale = locale;
res.updateConfiguration(newConfig, dm);
而且后两行已经提示deprecated了.
谢谢

commented

非常感谢你提出的疑问
languageToLoad 这个是我没写清楚
updateConfiguration 这个方法在 Api 25 是已经过时了, 我找到一个新的替换实例, 你可以去看一下
这两点我都在博文中更新说明了, https://github.com/Freelander/Blog/blob/master/201708/01.md