Question

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

Était-ce utile?

La 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());.

Autres conseils

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/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top