http://blog.csdn.net/sinat_25001099/article/details/50663265
一,需要在res下新建文件夹,大陆中文为values-zh-rCN,英文values-en-rUS,更多可以参考http://my.oschina.net/quttap/blog/204499,直接用values-zh,values-en也可以,可以自己查询,然后其下新建strings.xml,(注:android默认访问values下strings.xml,当设置其它语言找不到对应文件夹时,将转而访问values下的strings.xml)
二,通过getResources().getConfiguration().locale.getLanguage()来获取当前应用语言,中文为zh,英文为en,更多可以参考http://blog.sina.com.cn/s/blog_7981f91f01012wm7.html
String sta=getResources().getConfiguration().locale.getLanguage();
shiftLanguage(sta);
public void shiftLanguage(String sta){
if(sta.equals("zh")){
Locale.setDefault(Locale.ENGLISH);
Configuration config = getBaseContext().getResources().getConfiguration();
config.locale = Locale.ENGLISH;
getBaseContext().getResources().updateConfiguration(config
, getBaseContext().getResources().getDisplayMetrics());
refreshSelf();
}else{
Locale.setDefault(Locale.CHINESE);
Configuration config = getBaseContext().getResources().getConfiguration();
config.locale = Locale.CHINESE;
getBaseContext().getResources().updateConfiguration(config
, getBaseContext().getResources().getDisplayMetrics());
refreshSelf();
}
}
public void refreshSelf(){
Intent intent=new Intent(this,CustomerManagementActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}