Android开发_关于中英文切换


    开发APP过程中可能要有中文模式和英文模式,切换后控件要随着进行更改,以下代码可以很好的实现:

public static int getResourcesId(Context context, String resName,
            String resTpye) {
        String language = Locale.getDefault().getLanguage();
        String resString = resName + "_eng";
        if (language.contains("zh")) {
            resString = resName + "_cn";
        } else {
            resString = resName + "_eng";
        }
        return context.getResources().getIdentifier(resString, resTpye,
                context.getPackageName());
    }

 再调用以上方法

mSharePictureToBack.setBackgroundResource(Utils.getResourcesId(MyApplication
                .getAppContext(), "share_transmission_blue_back_style", "drawable"));

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM