简体   繁体   English

在Android对话框中显示URL中的图像

[英]Displaying a image from a URL in Android dialog

How would one go about displaying an image in the Android Dialog that is retrieved from the internet from a URL? 如何在Android对话框中显示从URL从Internet检索的图像? I have seen examples of Dialogs with pictures (like here: http://quickandroid.blogspot.com/2011/03/alert-dialog-with-list-of-text-and.html ) but all that I saw is how the piture is retrieved from the drawable folder. 我已经看到了带有图片的对话框示例(例如此处: http : //quickandroid.blogspot.com/2011/03/alert-dialog-with-list-of-text-and.html ),但是我所看到的只是从可绘制文件夹中检索piture。

How to display the image in a dialog from a URL? 如何通过URL在对话框中显示图像? Is dialog even the best choice? 对话甚至是最佳选择吗? Should I download the image first? 我应该先下载图像吗?

Thank you :) 谢谢 :)

you can use universal image loader to download image from web see the link bellow 您可以使用通用图像加载器从Web下载图像,请参见下面的链接

https://github.com/nostra13/Android-Universal-Image-Loader https://github.com/nostra13/Android-Universal-Image-Loader

Universal Image Loader is a good tip. Universal Image Loader是一个很好的技巧。 No need to download the picture yourself. 无需自己下载图片。 You can first download the picture with UIL, then inflate a Dialog from a layout (needs only contain an ImageView) and show the dialog. 您可以先使用UIL下载图片,然后从布局中添加一个Dialog (只需要包含一个ImageView),然后显示该对话框。 Or you can extend DialogFragment , download the picture and show it from there. 或者,您可以扩展DialogFragment ,下载图片并从那里显示。 If a dialog is the best way to show a picture is up to you and your app. 如果对话框是显示图片的最佳方式,则取决于您和您的应用。

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

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