0

I am trying to access a bunch of final static public ints from a class using reflection. This class however doesn't have a constructor - e.g. the android R.id . I am trying to get all int values for these, however I can't seem to access it due to the fact that you can't create the class. I was thinking of possible extending it just to create a constructor, but I am unsure this is wise. Any suggestions? I can't modify R.id or R.array (at least I shouldn't I think).

Thanks in advanced! Jon

Wim Coenen
  • 64,994
  • 13
  • 151
  • 241
Jon
  • 712
  • 7
  • 29

1 Answers1

3

That's all you need:

Field field = R.id.class.getField("some_var");
int value = field.getInt(null);
Vladimir Ivanov
  • 42,109
  • 17
  • 76
  • 102