鍍金池/ 問答/Java  Android  網(wǎng)絡(luò)安全/ Android 8.0 多語言適配問題

Android 8.0 多語言適配問題

在對Android 8.0進(jìn)行適配時遇到某些地方語言為轉(zhuǎn)化
主要是在動態(tài)添加二級view的時候語言未轉(zhuǎn)化

此外在語言更新上我已經(jīng)對版本進(jìn)行了判斷如
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {

   configuration.setLocale(targetLocale);

} else {

        configuration.locale = targetLocale;

}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {

     return mContext.createConfigurationContext(configuration);

}else{

     Resources resources = mContext.getResources();
     DisplayMetrics dm = resources.getDisplayMetrics();
     resources.updateConfiguration(configuration, dm);

}

之后會在相關(guān)的Application和BaseActivity中進(jìn)行配置

回答
編輯回答
單眼皮

解決了,是因為在相應(yīng)地方要引用相應(yīng)的上下文

2018年8月18日 19:56