问题
I have no idea how to get an Image URL from already settled ImageView. Actually, I have an ImageView over which picture is set from a URL. Now I have a button on that button_clik I have to fetch that ImageView URL. Is it possible or not ? Thanks in advance.
回答1:
u cannot get the image url from the imageview...infact u will have to use the alternate. For example u might be saving the urls for the imageview in some array...u need to get the position of the imageview clicked and using that position u can get the url of the clicked image...if u r using listview/gridview it is very easy to get the position but if not, u can set the pos as tag of image and retrieve the tag that will specify the position.
if u need help feel free to ask...
回答2:
I think you can't get URL from ImageView. What you can do is you can store the URL in variable or SharedPreference when you are setting image in ImageView so next time when you want to fetch URL you can directly get it from variable or SharedPreference.
回答3:
By Using Picasso Lib Picasso.with(contxt).load(imageurl).placeholder(R.drawable.ic_launcher).into(imageview);
来源:https://stackoverflow.com/questions/32558021/how-to-get-image-url-from-a-imageview