如设置成英文: Locale currentLocal = Locale.US; public void switchLanguage(Locale locale) { Resources res = getResources(); Configuration config = res.getConfiguration(); DisplayMetrics dm = res.getDisplayMetrics(); config.locale = locale; getResources().updateConfiguration(config, null); getResources().flushLayoutCache(); res.updateConfiguration(config, dm); Intent intent = new Intent(this, Activity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(intent); }
为确保在你程序操作过程中APP文字不被更新成系统文字还需要做如下操作:
@Override public void onConfigurationChanged(Configuration newConfig) { // 当新设置中,屏幕布局模式为横排时 switchLanguage(currentLocal); super.onConfigurationChanged(newConfig); }