Dnaso
Dnaso

Reputation: 1365

How to get the drawable name from my image in a list view Android

Ok so I have a list view with a custom list view adapter, and each list item has an "icon". when I click the list item, I am easily able to get all the text field names such as name address etc. I have their icon in an image view (obviously every icon is in the same id because it is getting reused in the listview). my question is how can i get the r.drawable.resource (ie pic1) when i click the list item . and pass it to my next intent (I know how to use bundle extras).

I have been searching and I can set the resource but cannot retrieve it from a imageview. Passing the Image in PutExtra in Android

most answers I have seen are like the link above, and this assumes that you either have different ids for each image view or that you want to turn the image view into bytes(do not want to do that). does anyone know how to get the r.drawable from the image view?

ImageView myimage = (ImageView) view.findViewById(R.id.myrate);

Upvotes: 0

Views: 3520

Answers (1)

dors
dors

Reputation: 5872

When you set the imageView's drawable, you can set the ImageView's tag:

imageView.setTag(R.drawable.my_drawable);
imageView.setDrawableResource(R.drawable.my_drawable);

And later use:

imageView.getTag();

Upvotes: 2

Related Questions