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 中 getResources() 方法获取资源标识符的方法。通过两种不同方式展示如何为特定位置的图片资源设置 drawable 路径。
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);
416
2637

被折叠的 条评论
为什么被折叠?