获取字符串从Android中不同价值观的文件夹字符串、中不、价值观、文件夹

2023-09-06 15:44:05 作者:餘煙濁眼

我要开发不同类型的语言android应用。所以,我已经使用本地化它。对于我创建值分别为值-FR,价值观-JA,价值观德文件夹。 n您还可以根据该值文件夹的静态价值创造的strings.xml。所以,一切都很好。但现在我的问题是,我想根据用户的语言选择更改UI文本。所以,我怎么能手动值时─> string.xml为特定的语言获得特定的字符串值???

我觉得可能很容易,但我也没办法。

谢谢,

解决方案

 区域设置区域=新区域(CN);Locale.setDefault(区域);配置配置=新配置();config.locale =区域;。getBaseContext()getResources()updateConfiguration(。配置,getBaseContext()getResources()getDisplayMetrics()); 

http://developer.android.com/guide/topics/resources/localization.html

I wanna develop android application for different types of languages. So I have used localization for it. For that I have created different values folder like values-fr, values-ja , values-de. N also created strings.xml with static value according to that values folder. So All is good. But now my question is that I wanna change UI text according to user's selection of language. So How can I manually get particular string values from values->string.xml for particular language???

android str字符串按2字节放入byte中 凯哥带你从零学大数据系列之Java篇 第十三章 字符串...

I think it may be easy, But I have no idea.

Thanks,

解决方案

Locale locale = new Locale("cn");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale; 
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());

http://developer.android.com/guide/topics/resources/localization.html