您的位置:首页 > 移动开发 > Android开发

android修改显示语言简单实现

2013-12-22 18:52 316 查看
简单的写下,。

public static void switchLanguage(String language, Context context) {
		Locale aLocale;
		if (language.equals("cn")) {
			aLocale = Locale.SIMPLIFIED_CHINESE;
		} else if (language.equals("cnt")) {
			aLocale = Locale.TRADITIONAL_CHINESE;
		} else {
			aLocale = new Locale(language);
		}

		Resources resources = context.getResources();// 获得res资源对象
		Configuration config = resources.getConfiguration();// 获得设置对象
		DisplayMetrics dm = resources.getDisplayMetrics();// 获得屏幕参数:主要是分辨率,像素等。
		config.locale = aLocale; 
		resources.updateConfiguration(config, dm);
	}


可以在menifest里面加这么一句话:
<supports-screens android:anyDensity="true"/>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: