You want to get the object ID as a String from the View object.

You can get the id using

view.getId() 

But then the number returns, but I need something else:

So:

  R.id.textView 

or so

 tetView 
  • Explain why do you need it? - katso
  • It doesn't work like that. R.id.textView is a variable in the autogenerate class R. And without wild hacks in Java, you can access variables in runtime, giving them a name is not necessary. You are solving your problem completely differently - describe a specific task, and not an attempt to solve it. - Yuriy SPb
  • I gave the answer, it is possible. But I will join my colleagues: it should not be necessary to get the view id as a string. - tse
  • There are many clickable TextView elements with almost identical content. So I want to bind the contents of TextView elements to an array. Because There are many elements and identical actions are performed for them, then 1 Listener was used. This is where you need to determine which id of the TextView element in order to know which element of the array to assign the contents to - Looney
  • In theory, a single listener distributes actions to switch(view.getId()){case R.id.textView1: someAction(); break; case R.id.textView2: anotherAction(); break;} switch(view.getId()){case R.id.textView1: someAction(); break; case R.id.textView2: anotherAction(); break;} switch(view.getId()){case R.id.textView1: someAction(); break; case R.id.textView2: anotherAction(); break;} etc - YuriySPb

1 answer 1

 getResources().getResourceEntryName(int resid); 

or

 getResources().getResourceName(int resid); 
  • Thank you, the top option came up =) - Looney