中英文语言切换 Locale.CHINA

系统中英文切换,一开始以为很难,其实理解了很简单的,再次和大家分享下

			//判断系统中英文
			Configuration mConfiguration = getResources().getConfiguration();
			Locale isCN = Locale.CHINA;
			if(mConfiguration.locale.equals(isCN)){ 
				mCityViewHolder.txt_city.setText("江苏");
			}else{
				mCityViewHolder.txt_city.setText("jiangsu");
			}
			getResources().updateConfiguration(mConfiguration, getResources().getDisplayMetrics());


解释下:

第一步、判断系统语言

Configuration mConfiguration = getResources().getConfiguration();

第二步、设置系统默认为中文,

Locale isCN = Locale.CHINA;

if(mConfiguration.locale.equals(isCN)){

     mCityViewHolder.txt_city.setText("江苏");

}else{

     mCityViewHolder.txt_city.setText("jiangsu");

}

第三步:更新系统配置

getResources().updateConfiguration(mConfiguration, getResources().getDisplayMetrics());

好了。以上就达到中英文切换的目的了。

 

另推荐一博客,不知道叫啥名字的大神,看这个博客挺不错的,保存下并和大家分享下,http://f120412352.iteye.com/blog/1464625

 


版权声明:本文为qq_16505961原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。