问题
I have added 720 new images to my Drawable
folder, but none of them are being recognized when I use Field[] drawables = android.R.drawable.class.getFields();
.
Field[] drawables = android.R.drawable.class.getFields();
for (Field f : drawables) {
try {
System.out.println("R.drawable." + f.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
This just returns a list of the images added by default to the Drawable
folder. I also tried getDeclaredFields
but no success.
回答1:
You need to use your own generated R class, that's your.package.name.R.drawable
.
来源:https://stackoverflow.com/questions/41595859/images-added-to-drawable-folder-not-being-recognized-when-the-getfields-method