获取字符串从Android中不同价值观的文件夹 [英] Get String From Different Values Folder in Android

查看:76
本文介绍了获取字符串从Android中不同价值观的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

谢谢,


解决方案

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

<一个href=\"http://developer.android.com/guide/topics/resources/localization.html\">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???

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

这篇关于获取字符串从Android中不同价值观的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆