Set Locale programmatically

后端 未结 14 1443
Happy的楠姐
Happy的楠姐 2020-11-22 05:55

My app supports 3 (soon 4) languages. Since several locales are quite similar I\'d like to give the user the option to change locale in my application, for instance an Itali

14条回答
  •  醉话见心
    2020-11-22 06:35

    I found the androidx.appcompat:appcompat:1.1.0 bug can also be fixed by simply calling getResources() in applyOverrideConfiguration()

    @Override public void
    applyOverrideConfiguration(Configuration cfgOverride)
    {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
          Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
        // add this to fix androidx.appcompat:appcompat 1.1.0 bug
        // which happens on Android 6.x ~ 7.x
        getResources();
      }
    
      super.applyOverrideConfiguration(cfgOverride);
    }
    

提交回复
热议问题