读书人

批改语言环境方法

发布时间: 2012-07-01 13:15:00 作者: rapoo

修改语言环境方法

修改语言环境方法

?

?

private void setLocale(Locale locale) {        try {            IActivityManager am = ActivityManagerNative.getDefault();            Configuration config = am.getConfiguration();            config.locale = locale;            config.userSetLocale = true;            am.updateConfiguration(config);          } catch (RemoteException e) {        }}setLocale(Locale.ENGLISH);  //设置成英语setLocale(new Locale("es_ES"));////设置成西班牙语setLocale(Locale.SIMPLIFIED_CHINESE);  //设置成简体中文setLocale(Locale.KOREA);//设置成韩语//获取语言环境private static final int LAN_ENG = 0;private static final int LAN_ESP = 1;private static final int LAN_CHN = 2;private static final int LAN_KOR = 3;private int getLocaleId() {        String languageCode = Locale.getDefault().getLanguage();        Log.e(TAG , languageCode);if (languageCode.equals("en"))return LAN_ENG;if (languageCode.equals("es_es"))return LAN_ESP;if (languageCode.equals("zh"))return LAN_CHN;if (languageCode.equals("ko"))return LAN_KOR;return -1;} 

??

?

读书人网 >移动开发

热点推荐