0

Basically what I am trying to do is,

I start with MainActivity(activity_main) go to SettingActivity(activity_setting) & change my locale from given options(like french, english, dutch etc.)

So what I have done till now is...

OnClick of language name it re-create SettingActivity(activity-setting) & change it's string values according to language selected.

What I really want is Without re-creating Activity, All string values should be applied according to that selected language.

All suggestions & Answers are greatly appreciated. Thank you in Advance.

buzzingsilently
  • 1,546
  • 3
  • 12
  • 18
  • 1
    Related: [How to change android app language without changing phone language?](http://stackoverflow.com/questions/39942736/how-to-change-android-app-language-without-changing-phone-language) – Markus Kauppinen Oct 14 '16 at 08:42

1 Answers1

0

Simply change the language property first. Then call a new function that sets all strings displayed in the UI to the right language.

Pseudocode:

TextView myTextView = (TextView) findViewbyId(R.id.tv1);
myTextView.setText(yourCustomGetLocaleFunction("some id of the string you want to display", "some language name"));

But that's a bad approach. You should let Android handle the language of your app. Just localize the strings.xml file (you can load strings from the file from code).

Edit:

To change the language of your app for the moment, you can use the Code from this solution: How to change android app language without changing phone language?

Community
  • 1
  • 1
Felix
  • 824
  • 8
  • 21