I create a ListPreference with a few languages in setting menu of my app. I used the following code to change the language based on user choice :
findPreference("language_list").setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String loadLanguage = (String) newValue;
Locale locale = null;
if (loadLanguage.equals("en")) {
locale = new Locale("en");
} else if (loadLanguage.equals("ku")) {
locale = new Locale("ku");
} else if(loadLanguage.equals("ar")){
locale = new Locale("ar");
}else if(loadLanguage.equals("tr")){
locale = new Locale("tr");
}
else if(loadLanguage.equals("fr")){
locale = new Locale("fr");
}
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getActivity().getResources().updateConfiguration(config,
getActivity().getResources().getDisplayMetrics());
return true;
}
});
the code works but it is needed to restart the app (exit and start it again) till language change be done completely. with the above code some part of the app will remains and do not change even they do not work.
could you please give me an idea what should I do for this?
Thank you