GoogleMaps Android Studio更改语言刷新 [英] GoogleMaps Android studio change language refresh
问题描述
我在一个有多个片段的活动中使用google map,当从设置页面将语言从英语更改为阿拉伯语,反之亦然时,我重新加载整个活动以应用更改,所有事物通常显示为所有文本更改新语言,但地图内的标题(国家名称,城市,街道...)
I am using a google map in an activity with multiple fragments, when changing the language from English to Arabic and vice versa from the settings page, i reload the whole activity to apply changes, every thing displays normally ei all text changes to the new language except the titles inside the map (country names, city, streets...)
这是我用来更改语言的代码:
this is the code i use to change the laguage:
public static void setLanguage(Activity activity){
String languageToLoad = "en";
boolean isEnglish=Preference.getBooleanPrefs(Preference.LANGUAGE, activity, true);
if(isEnglish)
languageToLoad = "en";
else
languageToLoad = "ar";
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
activity.getBaseContext().getResources().updateConfiguration(config,activity.getResources().getDisplayMetrics());
}
这是我用来重新加载活动的代码:
this is the code i use to reload the activity:
public void refreshChangelanguage() {
Intent intent = new Intent(this, HomeActivity.class);
startActivity(intent);
finish();
loadFragment(FRAGMENT_SETTING, null);
}
地图会一直以旧语言显示,直到我手动从堆栈列表中杀死整个应用程序,然后重新打开它,如何强制地图以新语言重新加载标签?
the map keeps displaying in the old language until i kill the whole app from the stack list manually then reopen it, how can i force the map to reload the labels in the new language?
先谢谢您
推荐答案
我想说,您必须在Activity的super.onCreate
之后和setContentView
之前执行setLanguage(Activity activity)
.
I'd say you have to do the setLanguage(Activity activity)
after the super.onCreate
and before the setContentView
on the Activity.
这篇关于GoogleMaps Android Studio更改语言刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!