我有语言转换器正在活动中。在我目前的情况下,我使用recreate()
,但这样它重绘了第一个片段。示例:我有四个页面是片段。当我说第四,我改变语言 - 它重绘第一个。有没有办法改变当地的活动,并说当前的片段(当然是翻译过的)?
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
int check = 0;
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
check = check + 1;
if(check>1) {
switch ((int)id) {
case 0:
locale = new Locale("fr");
break;
case 1:
locale = new Locale("en");
breakk
}
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
recreate();
}
}
public void onNothingSelected(AdapterView<?> parent) {
}
});