zoukankan      html  css  js  c++  java
  • Android应用程序的语言切换

    参考: http://www.cnblogs.com/error404/archive/2013/04/09/3010514.html

    http://bbs.51cto.com/thread-1075165-1.html

    1.添加权限: <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />

    2.资源文件夹 values-en values-zh 等

    3.代码:

    public void switchLanguage(Locale locale) {
                     Configuration config = getResources().getConfiguration();// 获得设置对象
                     Resources resources = getResources();// 获得res资源对象
                     DisplayMetrics dm = resources.getDisplayMetrics();// 获得屏幕参数:主要是分辨率,像素等。
                     config.locale = locale; // 简体中文
                     resources.updateConfiguration(config, dm);
             }

    4.当时不会生效  必须finish act 重新启动

  • 相关阅读:
    Go标准库之tar
    redis必知必会
    GORM CRUD指南
    GORM入门指南
    MUI中tap点击事件点击一次连续申请两次
    Go代码启动默认浏览器
    Go实现JWT
    Go Micro
    protobuf初识
    英语作文
  • 原文地址:https://www.cnblogs.com/wjw334/p/4362246.html
Copyright © 2011-2022 走看看