2017-08-17 112 views
0

我已经按照这个ans的设置实现了更改语言,但是在杀死我的应用程序后,应用程序的一些屏幕变成了英文。语言更改为阿拉伯语不起作用?

我已经实现代码如下 代码闪屏

String deviceLanguage = Locale.getDefault().getLanguage(); 

if (!"en".equalsIgnoreCase(deviceLanguage) && !"ar".equalsIgnoreCase(deviceLanguage)){ 
      deviceLanguage="en"; 
     } 
((AppController)getApplication()).appLang= Utilities.getSaveData(this, getString(R.string.key_language),deviceLanguage); 

代码详细活动

@Override 
protected void attachBaseContext(Context newBase) { 
    super.attachBaseContext(MyContextWrapper.wrap(newBase, ((AppController)newBase.getApplicationContext()).appLang)); 
} 

注:我在一个有这个问题,加上3T设备和genymotion仿真器5.1的Android版本

+0

的实际问题为提及的活动是定制的操作系统,在一些定制的操作系统,他们可以选择多种语言同时,它创造的问题 – Krutik

回答

0
final Resources res = appContext.getResources(); 
final Configuration conf = res.getConfiguration(); 
conf.locale = new Locale("ar", "AE");  
res.updateConfiguration(conf, null); 

更新配置后,Rest图片下方

finish(); 
final Intent intent = getIntent(); 
startActivity(intent); 
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); 
+0

这样的事情,但我宁愿把区域设置成'应用程序“,并在更改后重新启动整个应用程序,而不仅仅是当前的活动我不记得任何细节(因为我上次做了类似的事情,就像3-4年前一样),但是在一些旧版本的Android和某些设备上的IIRC,只重新启动Activity可能会产生一些不需要的人为因素,使用原始的Locale保持初始化。 – Ped7g

相关问题