android -语言设置
来源:互联网 发布:云软件哪个好 编辑:程序博客网 时间:2024/04/29 15:11
在android中语言适配 响应国际化,一种场景是手动进行语言切换 ,另一种是根据定位得到国家码匹配。
这里仅对中英文切换配置:
1.在res文件下创建对应的values-en文件夹 和 values-zh文件夹 创建所属strings.xml;
如: values-en下strings.xml 中<stringname="hello_world">hello word</string>
:values-zh下string.xml 中<stringname="hello_world">您好,世界</string>
2.更新Configuration中的locale属性:
public static void resetLanguage(int language){// int language = SPHelper.getInt(SpKeys.SP_KEY_LANGUAGE); //根据读取到的数据,进行设置 Resources resources = App.get().getResources(); DisplayMetrics displayMetrics = resources.getDisplayMetrics(); Configuration configuration = resources.getConfiguration(); switch (language){ case 0: configuration.setLocale( Locale.CHINESE); break; case 1: configuration.setLocale(Locale.ENGLISH); break; default: configuration.setLocale(Locale.getDefault()); break; } resources.updateConfiguration(configuration,displayMetrics); // restart 重新启动首页 App.reStart(); }
阅读全文
0 0
- Android的语言设置
- android 语言设置
- android 语言设置2
- android读取语言设置
- android语言设置
- android 语言设置修改
- android语言设置
- android多语言设置
- android多语言设置
- android 语言设置修改
- android多语言设置
- android设置显示语言
- Android的语言设置
- Android Local语言设置
- android设置系统语言
- android 设置语言类型
- android 设置默认语言
- Android 系统语言设置
- 掌握了这些,妈妈再也不怕我画不出思维导图了!
- MYSQL中空白判断无效的解决办法
- path路径不小心删了恢复办法
- Perl之单行命令特技
- redis cluster设置密码
- android -语言设置
- 如何在VS2017版本的软件中运行JAI_SDK_sample工程
- 【新手教程】win2008 ftp图文教程_从此ftp再也不是个问题啦
- hive常用优化
- 阿里云加密服务基本认识(下篇)
- 前端面试
- 【LeetCode】657.Judge Route Circle
- 极光推送消息的自动集成与手动集成
- 215. Kth Largest Element in an Array(快排的分治思想)