Phil
Phil

Reputation: 1

getResource ID of Drawable shown in View v

I am Trying to do something similar to this and I have Problems, too. I am using dynamic ImageViews on my Screen. Per OnClickListener I am changing the Resource ID's of the Views.

I want to be able to tell what the Resource ID of the Drawable shown in the View that was clicked is.

OnClickListener(View v)
{
ImageView temp=(ImageView)v;
//I Can change Image Resource of the Clicked View with this->

temp.setImageResource(R.drawable.picture_1);

//but how can I find out what Resource ID the Drawable has that is  displayed in the View?
//(I'm searching for a method   ->temp.getImageResource();)

}

Thanks for your help! Philipp

Upvotes: 0

Views: 1522

Answers (1)

drewi
drewi

Reputation: 689

Something like this should work

temp.setImageResource(R.drawable.picture_1);
temp.setTag(R.drawable.picture_1);

and then to get the resource id

temp.getTag();

Upvotes: 1

Related Questions