Reputation: 15
I am trying to change the language for my android app, however I could not do it.
I used string.xml
to add my text and called it in my text views in my activities.
However, I have so many text Views.
I need to create as many string names or is there any possibilty to change if i add some text views.
I have so many textViews and also so many activities.
Please guide me.
I used string.xml to add my text and called it in my text views in my activities.
Upvotes: 1
Views: 176
Reputation: 788
One way could be using sharedPrefrences
, (specially in case of only two languages);
Create your source of String
s in both languages. Do it anyway you like.
Create the UI which user will use it to change the language. By this View
you should change the value of the respected sharedPreference
. The values would be "languageOne" and "languageTwo", or booleans.
In all textViews
, editTexts
, and etc set the text like this: view.setText(sharedPreferenceValue.equals("languageOne")?"theStringInLanguageOne":"theStringInLanguageTwo");
Upvotes: 1