重新启动一个任务活动
答
如果您使用API 11以上,你可以使用:
Activity.recreate()
如果需要支持较低API使用此再次调用您的活动:
Intent i = getIntent();
finish();
startActivity(i);
答
如果我们使用这种方法我们不需要重新开始活动
用以下代码更改您的应用语言:
public static void notifyForLanguageChange(Context context, String languageCode) {
Resources res = context.getResources();
// Change locale settings in the app.
DisplayMetrics dm = res.getDisplayMetrics();
android.content.res.Configuration conf = res.getConfiguration();
conf.locale = new Locale(languageCode.toLowerCase());
res.updateConfiguration(conf, dm);
}
,之后改变与(即重新加载字符串资源)
public void setLabels() {
txtFirstView.setText(R.string.first);
txtSecondView.setText(R.string.second);
btnThirdView.setText(R.string.third);
}
屏幕标签