Search code examples
androidandroid-tabhostpreferenceactivity

How to refresh PreferenceActivity (which launched from TabHost) after changing language (Locale) inside android-application


I`m new in android and would like ask one question. My application users can change the language from the app's settings. I update Config after user have made your choise. But how I can update the all Views in the screen (at PreferenceActivity with TabHost) without restarting the whole application (this variant I know but this way as I read in Google are not desirable). Changing language inside application we should make 2 steps: 1. Create new Configuration with our new locale, then upgate Configuration; 2. Update Views by relaunching application or update view by resetting ContenView. In my case I addPreferencesFromResource(R.xml.ulticlockwidget_settings) for the first time. Could you suggest to me how to change the language in my application and properly change the whole Views at the screen? I would be appreciate to all advices.


Solution

  • If your application don't have too much preferences, you can always get them one by one and reset their text. When you set the text again, it automatically find the right text with new locale

    Another option is to restart preferences activity. You don't have to restart the whole app. Just open the preferences activity again and finish() the old preference activity instance.