3
我創造了ENGLSIH多語言應用和印地文Android的語言環境和updateConfiguration已過時
下面的代碼,我用其完美的工作,但有些東西是從它過時了,只是告訴我該怎麼解決呢,
棄用代碼是
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
我的整個代碼(這是不完整的代碼我只是顯示你的主要組成部分)
private Intent intent;
private Locale myLocale;
private Resources res;
private DisplayMetrics dm;
private Configuration conf;
switch(lang)
{
case "no_lang":
editor = preferences.edit();
editor.putString("set_language","en");
editor.commit();
myLocale = new Locale("en");
res = getResources();
dm = res.getDisplayMetrics();
conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
break;
case "en":
editor = preferences.edit();
editor.putString("set_language","en");
editor.commit();
myLocale = new Locale("en");
res = getResources();
dm = res.getDisplayMetrics();
conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
break;
case "hi":
editor = preferences.edit();
editor.putString("set_language","hi");
editor.commit();
myLocale = new Locale("hi");
res = getResources();
dm = res.getDisplayMetrics();
conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
break;
}
我遵循這些鏈接,但我沒有得到它... link1, link2