2

I have a view and i have it's resource id ( i.e. R.id.xxx ) and i want to extract the xxx part and convert it to a String.

Is that possible to do?

Just to be clear, I have view.getId() a resource integer, not the actual name of the id.

Sufian
  • 6,405
  • 16
  • 66
  • 120
Pavle Pavlov
  • 189
  • 2
  • 13

2 Answers2

11
View v;
String ResourceIdAsString = v.getResources().getResourceName(v.getId());

Use this in the view constructors

Sufian
  • 6,405
  • 16
  • 66
  • 120
CodeWalker
  • 2,281
  • 4
  • 23
  • 50
4

You can use

   getResources().getResourceEntryName(int resid);
Ankii Rawat
  • 2,070
  • 17
  • 17