How do you get the resource name through the interface onItemClickListener?
-
I have
GridView
there are several images. With helpOnItemClickListener
and methodonItemClick()
I can get it.position
The clicked element, but it's not good for me because one element can be in different places. How do I get the name of the resource of the clicked element throughView
?gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { //тут нужно получить имя ресурса } });
-
Apparently.
View
However, the ID resource that is in the process cannot be obtainedView
by direct meansView
)Appropriation
View
Resource value, record this value in the tag:imageView.setImageResource( R.drawable.imageN); imageView.setTag(R.drawable.imageN);
Then you can get the meaning of that.
View
that passes the bell:public void onItemClick(AdapterView<?> parent, View v, int position, long id) { int id = v.getTag(); }