简体   繁体   English

如何从 ImageView 获取图像 URL

[英]How to get Image URL from a ImageView

I have no idea how to get an Image URL from already settled ImageView .我不知道如何从已经解决的ImageView获取图像 URL Actually, I have an ImageView over which picture is set from a URL .实际上,我有一个ImageView ,其图片是从URL设置的。 Now I have a button on that button_clik I have to fetch that ImageView URL .现在我在那个button_clik上有一个按钮,我必须获取那个ImageView URL Is it possible or not ?有可能吗? Thanks in advance.提前致谢。

u cannot get the image url from the imageview...infact u will have to use the alternate.你无法从图像视图中获取图像 url ......事实上你将不得不使用替代。 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 ur 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.例如,您可能将图像视图的 url 保存在某个数组中...您需要获取点击的图像视图的位置,并使用该位置您可以获得点击图像的 url...如果您使用 listview/gridview 它很容易获得位置,但如果没有,您可以将 pos 设置为图像的标签并检索将指定位置的标签。

if u need help feel free to ask...如果您需要帮助,请随时询问...

I think you can't get URL from ImageView .我认为您无法从ImageView获取URL 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 .你可以做的是,当你在ImageView中设置图像时,你可以将URL存储在变量或SharedPreference 中,这样下次当你想要获取URL 时,你可以直接从变量或SharedPreference获取它。

通过使用 Picasso Lib Picasso.with(contxt).load(imageurl).placeholder(R.drawable.ic_launcher).into(imageview);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM