简体   繁体   中英

Programmatically changing the language within the Android app using string resources?

I am relatively new to Android and want to know how to change the language of my app on the click of a button? I have extracted all the text and stored was string resources and set up new string resource files for each of the languages. My problem is around the mainActivity.java class.

There is a library for the behaviour you want. It is called the localization library . You have to extend the libraries LocalizationActivity. You can than use setLanguage("en"); to change the language of your application at runtime. There is also a sample project available on the libraries GitHub page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM