Question

I need help to count how many pictures in drawable with criteria substring filename? like how many pictures with filename starting "SC" ?

Was it helpful?

Solution

You can use reflection for that. Simply use getDeclaredFields() to get all fields of R.drawable.class. Then, just loop through them, look for the search term in the field names and get the drawable using Resources.getDrawable(Field.getInt());.

OTHER TIPS

Well,

I haven't tried it but you can use getFields() to get all the variables

R.drawable.class.getFields()

Then you can perform your search for specific file name accordingly.

See this to know more for Reflections in Java: http://www.ibm.com/developerworks/library/j-dyn0603/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top