根据图片名字在drawable中得到图片 int imageId = context.getResources().getIdentifier("图片的名字","drawable", "包名"); //iv是ImageView iv.setImageResource(imageId );