android - How to count items in a directory? -
i need count number of items in directory in android, example; how many files there in "layout" directory?
if count array do
(int = 0; < array.lenght; i++){ count++; }
how change "array.lenght" suitable directory? i'm doing because want create x-number of views depending on amount of items in drawable. if add new ".xml" in drawable directory, app generate view item automatically because of for-loop.
the android resources identified constants in r class generated aapt. reflection can count number of fields (e.g. drawables):
int getdrawablescount() { return r.drawable.class.getfields().length; }
Comments
Post a Comment