获取resId

For example: I have a file bug.png in the "/res/drawable/ ", so i get its ResourceID with the following code:
int resID = getResources( ) .getIdentifier ( "org.anddev.android.testproject:drawable/bug" , null , null ) ;
// or
int resID = getResources( ) .getIdentifier ( "bug" , "drawable" , "org.anddev.android.testproject" ) ;

你可能感兴趣的:(android)