/** * 根据图片的名称获取对应的资源id * @param resourceName * @return */ public int getDrawResourceID(String resourceName) { Resources res=getResources(); int picid = res.getIdentifier(resourceName,"drawable",getPackageName()); return picid; }
原文地址:http://blog.csdn.net/sange77/article/details/41038693