I know that the multiple language support can be obtained by maintaining different strings.xml in folders like values , values-it('it' incase of italian) and the app will show the contents in the language which is the device's language . My question is I have my app , that people of my region would like in local language [Marathi / Hindi] . Initially I will provide screen that would allow me to choose English/Hindi/Marathi .I am struck , how to programmatically apply them !

Thanks

有帮助吗?

解决方案

Try to set your selected Language on this way:

Locale locale = new Locale("YourSelectedLang");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
        getBaseContext().getResources().getDisplayMetrics());
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top