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
  • 66,094
  • 13
  • 157
  • 251
Jon
  • 734
  • 1
  • 7
  • 30

1 Answers1

3

That's all you need:

Field field = R.id.class.getField("some_var");
int value = field.getInt(null);
Vladimir Ivanov
  • 42,730
  • 18
  • 77
  • 103