int igotit = getResources().getIdentifier(val,"drawable",getPackageName());
我从如何显示imagename获得了resourceid?
String imageName = getResources().getResourceName(R.id.img);
参考doc.还有方法:getResourceEntryName(int)