sometimes we need to dynamically get the ID of a control, and then do the operation, after searching the web, find a way getresources (). Getidentifier ("TextView01", "id", "cn.xxx.xxx");
The first parameter is the ID name, the second is the resource attribute is the ID or the drawable, and the third is the package name .
The following information is available from the Web:
Mainly consists of two methods, the individual suggests the second.
1. Instead of placing the picture under Res/drawable, it is stored in a SRC package (for example: Com.drawable.resource), in which case the call method is:
String path = " Com/drawable/resource/image.png ";
InputStream is = getClassLoader (). getResourceAsStream (path);
Drawable.createfromstream (IS, "src");
2. If you still want to use the image in res/drawable directly, you need to go through the following method:  
Assuming that the project was created , fill in the package name: com.test.image
int resID = Getresources (). Getidentifier ("Goto_radar", " Drawable "," com.test.image ");
drawable image = Getresources (). getdrawable (ResID);