Issue
I want to allow the user of my Android app to change the language of the app. I know that I need to write code that would change the locale (e.g., from English to Russian). However, what if I want to change from English to a language that doesn't have locale? Can I create a locale just for this app and have folders like "values-xx", where "xx" would be a new locale?
Thanks
Solution
I did it myself. I changed the locale using this code:
Resources res = context.getResources();
Configuration configuration = res.getConfiguration();
configuration.locale = new Locale("XX"); //"XX" is language code, even if language is unsupported
res.updateConfiguration(configuration, res.getDisplayMetrics());
I also needed to create a new "values-xx" folder and put resource files there.
Answered By - user3623874
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.