我有这个方法运行在大多数Android API版本上使用语言(字符串等)设置应用程序
protected void setDefaultLocale(Context context, Locale locale) {
Locale.setDefault(locale);
Configuration appConfig = new Configuration();
appConfig.locale = locale;
context.getResources()
.updateConfiguration(appConfig, context.getResources().getDisplayMetrics());
System.out.println("trad" + locale.getLanguage());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
String language = sharedPref.getString("pref_language", "he_IL");
if (!language.equals(""))
setDefaultLocale(this, new Locale(language));
super.onCreate(savedInstanceState);
}
Run Code Online (Sandbox Code Playgroud)
在棒棒糖运行设备上使用时没有任何改变.
有谁知道如何解决这个问题?