What I want to do is provide the user with a spinner which contains several languages, when a language is selected, the app will translate to that language.
I have different string files but I have no idea how to implement this. Is this possible? How can I do it?
In the res folder, respect this :
res/
values/
strings.xml
values-es / (here for spanish values)
strings.xml
values-fr /
strings.xml (here for french values)
Android loads the appropriate resources according to the locale settings of the device at run time.
For more informations, see this.
you just need to put different string.xml
files in different values folders each one named like this values-XX where XX is the language to be used.
for examlple values-en for english, values-fr for french, etc..
来源:https://stackoverflow.com/questions/12006280/translate-my-app