Reputation: 23
In my application i need to find out a source of the image in one ImageView so i can put that same image on another ImageView. I need actual source, and not just resource id, because i need to do other actions with it.
I tried with:
ImageView image = (ImageView) view;
String src = view2.getDrawable().toString();
but I want returned value to be something like:
some_packages/image.png
same like you get in c# with image.Source.ToString()
. Is it posible?
Sorry for my english and thank you for answer.
Upvotes: 2
Views: 5135
Reputation: 1007644
Is it posible?
Not the way that you are going about it. An ImageView
does not have to be populated by a resource. It can be using any sort of Drawable
. A Drawable
can also be created either in Java code or from a resource. So, neither an ImageView
nor the Drawable
inside of it will be able to tell you the resource that is used, as there may not be any such resource.
Either:
Hold onto the source somewhere else, or
Put the source in the tag of the ImageView
via setTag()
and retrieve it later via getTag()
Upvotes: 2