通过资源文件名获得资源ID

int resID = getResources().getIdentifier("gallery_photo_"+String.valueOf(position), "drawable", "org.loveandroid.androidtest");


int resID = getResources().getIdentifier("org.loveandroid.androidtest:drawable/gallery_photo_1",null,null);

你可能感兴趣的:(android,文件名,资源id)