开发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"));