I've create one layout with two image button. I want change language when button is pressed.
I've create res-values-it and res-values-en, now I can I do?
I've create one layout with two image button. I want change language when button is pressed.
I've create res-values-it and res-values-en, now I can I do?
i used this one for french
String languageToLoad = "fr_FR";
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
context.getResources().updateConfiguration(config,context.getResources().getDisplayMetrics());
Intent intent = new Intent(XYZ.this, XYZ.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
I think you have to add a settings Menu in wich user can select language that will be stored as a SharedPreference
. then when displaying text you have to get language from SharedPreferences
and use conditions to select text from res-values-it
or res-values-en
. i guess that should be usefull.