2012-07-17 215 views
0

我创建了一个具有一个TextView和Spineer的活动。 Spineer用于选择语言环境和选择我希望TextView文本应该从选定的语言环境中选取,并且我希望在Spineer关闭时立即更改它。
在onItemSelected方法我已经写了下面的代码:在运行时加载语言环境不会同时更新

selectedLocale=(String) arg0.getItemAtPosition(arg2); 

     if(selectedLocale.equals("Arabic")){ 
      locale2= new Locale("AF"); 
     } 
     else 
     { 
      locale2= new Locale("EN"); 
     } 



     Configuration config = new Configuration(); 
     config.locale = locale2; 
     Log.v("This file @onItem selected", "calling updatinon" + selectedLocale); 

     getApplicationContext().getResources().updateConfiguration(config, null); 

我的问题是,我不能够获取选定区域的文本。如果我错过了一些东西,任何人都可以更新我。

回答

0

我写了错误的onItemSelected代码流,每次在设置更新的区域设置后重新设置区域设置为旧的区域设置时调用该代码。

0

使用lower case的语言代码,例如:

new Locale("ar");  

ar导致Arabic地方。

+0

它不工作,如果我在更小的情况下更改语言环境名称。我的问题是通知系统配置更改已完成,现在恢复对活动的更改。 – 2012-07-18 06:10:30