سؤال

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

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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/

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top