在不同的 value 文件夹下(例如 value 、value-en、values-zh-rTW 文件夹)添加不同语言的 string.xml
文件
中文的string.xml文件翻译成英文的string.xml文件 http://fanyi.youdao.com/translate
//根据系统语言设置应用语言
private Resources resources;
private Configuration config;
private DisplayMetrics dm;
在app的入口(application)的oncreate方法中调用此方法
public void setlanguage()
{
//获取系统当前的语言
String able= getResources().getConfiguration().locale.getLanguage();
resources =getResources();//获得res资源对象
config = resources.getConfiguration();//获得设置对象
dm = resources.getDisplayMetrics();
//根据系统语言进行设置
if (able.equals("zh")) {
config.locale = Locale.SIMPLIFIED_CHINESE;
resources.updateConfiguration(config, dm);
}
else if(able.equals("en"))
{
config.locale = Locale.US;
resources.updateConfiguration(config, dm);
}
}
通过设置手机系统的语言改变AndroidApp的语言