How to get Image URL from a ImageView

2019-09-30 08:18发布

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.

3条回答
兄弟一词,经得起流年.
2楼-- · 2019-09-30 08:37

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...

查看更多
成全新的幸福
3楼-- · 2019-09-30 08:58

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.

查看更多
Melony?
4楼-- · 2019-09-30 09:01

By Using Picasso Lib Picasso.with(contxt).load(imageurl).placeholder(R.drawable.ic_launcher).into(imageview);

查看更多
登录 后发表回答