android - Iteration Through R class -


Is there any possible way to iterate RROR or Ardoable or any R-class? I have to dynamically get every ID on that folder.

  ArrayList resArray = new ArrayList (); Forchha (Int id: RO.A.) {resArray.add (ID); }   

Or is there any other way?

You can do this via Java reflection:

  class Raw = R.raw.class; Field [] fields = raw .getFields (); (Field field: field) {try.log (ii ("reflection", string.format ("% s is% d", field.getName (), field.getInt (null));} hold (IllegalAccessException e) {Log.e ("Reflection", String.format ("% s threw IllegalAccessException.", Field.getName ()));}}    

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -