androidcollectionsresourcesdrawable

Retrieving all Drawable resources from Resources object


In my Android project, I want to loop through the entire collection of Drawable resources. Normally, you can only retrieve a specific resource via its ID using something like:

InputStream is = Resources.getSystem().openRawResource(resourceId)

However, I want to get all Drawable resources where I won't know their ID's beforehand. Is there a collection I can loop through or perhaps a way to get the list of resource ID's given the resources in my project?

Or, is there a way for me in Java to extract all property values from the R.drawable static class?


Solution

  • If you find yourself wanting to do this you're probably misusing the resource system. Take a look at assets and AssetManager if you want to iterate over files included in your .apk.