小编Sac*_*per的帖子

棒棒糖设置默认本地不起作用

我有这个方法运行在大多数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)

在棒棒糖运行设备上使用时没有任何改变.

有谁知道如何解决这个问题?

android android-5.0-lollipop

8
推荐指数
2
解决办法
2896
查看次数

标签 统计

android ×1

android-5.0-lollipop ×1