How to display list of resource drawables [duplicate]

Using the getFields method on the drawable class, you are able to iterate through the entire list of drawables.

Field[] drawables = android.R.drawable.class.getFields();
for (Field f : drawables) {
    try {
        System.out.println("R.drawable." + f.getName());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Reference: http://www.darshancomputing.com/android/1.5-drawables.html

Leave a Comment