问题
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?
thank you in advance
回答1:
I'd say you have to do the setLanguage(Activity activity)
after the super.onCreate
and before the setContentView
on the Activity.
来源:https://stackoverflow.com/questions/42559878/googlemaps-android-studio-change-language-refresh