How to get Image URL from a ImageView

廉价感情. 提交于 2019-12-13 23:19:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!