Change language dynamically using androids multilanguage support?

▼魔方 西西 提交于 2019-12-17 15:57:20

问题


Is there are way to switch between different languages within an app using androids multilanguage support (values-de folder for german and value-en folder for english)?


回答1:


This is not really supported but possible by changing the Configuration object's "locale" field [Google Groups Post]

Configuration c = new Configuration(getResources().getConfiguration());
c.locale = Locale.GERMAN;
getResources().updateConfiguration(c, getResources().getDisplayMetrics());

Note that this alone will only effect future strings, not ones already displayed on the screen. You'd want to do this from a different activity than your main one, then finish your main one and restart it. This is hacky. See Post from Hackborn



来源:https://stackoverflow.com/questions/4639078/change-language-dynamically-using-androids-multilanguage-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!