Pergunta

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

Foi útil?

Solução

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

Outras dicas

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/

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top