0
耳目一新的應用程序我是迫使選項更改後的語言環境:強制語言環境和新的語言
public void forceLocale(Context ctx) {
Locale.setDefault(getCurrentLocale());
Configuration config = new Configuration();
config.locale = getCurrentLocale();
ctx.getResources().updateConfiguration(config, ctx.getResources().getDisplayMetrics());
}
我想顯示在一個新的語言環境的當前活動,但它doesen't發生。其他活動也是如此。
我想對我的所有活動的onResume()無效:
protected void onResume() {
//if no custom locale, restore default
if (StaticClass.locale.getCurrentLocale() == null)
StaticClass.locale.restoreDefaultLocale();
//force curretnt locale
StaticClass.locale.forceLocale(this);
//reload the view
ViewGroup vg = (ViewGroup) findViewById(android.R.id.content);
vg.invalidate();
super.onResume();
}
無影響。應用程序在從內存中清除並重新啓動後會被翻譯