使用机器人多语言支持动态改变的语言? [英] Change language dynamically using androids multilanguage support?
问题描述
时有办法在一个应用程序中使用的机器人不同的语言之间进行切换多语言支持(值德
文件夹,德语和值恩
文件夹中英文)?
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)?
推荐答案
这是不是真的支持,但可以通过改变配置对象的区域设置字段[Google论坛帖子]
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());
请注意,这本身将不仅影响今后的字符串,而不是那些在屏幕上已经显示。你会想从比你的主要的一个不同的活动做到这一点,然后完成你的主要之一,并重新启动它。 这是哈克。请参见后从Hackborn
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
这篇关于使用机器人多语言支持动态改变的语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!