Change Locale without refreshing and reloading the layout/fragment

999 views Asked by At

How can I change the locale/language without reloading the layout? We have to do the below to change the locale dynamically

mLocale = new Locale(LOCALE_ARABIC);
Locale.setDefault(mLocale);
Configuration config = new Configuration();
config.locale = mLocale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
MainActivity.this.setContentView(R.layout.activity_main);

but in my case I have fragments within fragments. My app structure is Activity has 8 replaceable fragments and again each of the fragments has 4 to 5 replaceable child fragments.

And I have a button to change the language in my main activity. so its almost impossible to load the particular fragment when user change the language.

Please let me know what is best way to change the locale in my above case

0

There are 0 answers