Android context.getResources.updateConfiguration() deprecated

后端 未结 7 703
死守一世寂寞
死守一世寂寞 2020-11-22 16:05

Just recently context.getResources().updateConfiguration() has been deprecated in Android API 25 and it is advised to use context.createConfigurationContext() instead.

7条回答
  •  天命终不由人
    2020-11-22 16:45

    Probably like this :

    Configuration overrideConfiguration = getBaseContext().getResources().getConfiguration();
    overrideConfiguration.setLocales(LocaleList);
    Context context  = createConfigurationContext(overrideConfiguration);
    Resources resources = context.getResources();
    

    Bonus : A blog article who use createConfigurationContext()

提交回复
热议问题