- 當我選擇另一種語言時,如何在所有活動中更改語言?如果我回到以前打開的活動,它仍然具有相同的配置。如何刷新該活動呢?
我使用這種方法:以編程方式更改語言
public void setLocale(String lang) {
Locale myLocale = new Locale(lang);
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
android.content.res.Configuration conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
Intent refresh = new Intent(this, Language.class);
startActivity(refresh);
finish();
}
- 我怎樣才能保存我的配置?如果我關閉了應用程序並再次打開,我想要最後的配置。