Android开发经验谈Android开发Android技术知识

Android国际化

2019-03-12  本文已影响8人  Anwfly

参考1:https://blog.csdn.net/Jason_996/article/details/78227452
参考2:https://blog.csdn.net/lanyeming2012/article/details/37776107

核心方法:

    Resources resources = getResources();
        Configuration config = resources.getConfiguration();
        DisplayMetrics dm = resources.getDisplayMetrics();
        if (language.equals("en")) {
            config.locale = Locale.ENGLISH;
        } else if (language.equals("zh")) {
            config.locale = Locale.SIMPLIFIED_CHINESE;
        } else {
            config.locale = Locale.getDefault();
        }
        resources.updateConfiguration(config, dm);
    }

国际化插件:https://github.com/westlinkin/AndroidLocalizationer

上一篇 下一篇

猜你喜欢

热点阅读