Android:从网络下载图像并在 gridview 上显示它们
我想创建一个程序,从网页获取一些图像,并将它们显示在网格视图上。我不知道到底有多少。可能是 20 到 30。我将使用 asynctask 来完成它,我之前已经使用过它并且或多或少知道它是如何工作的。但我不知道这次用什么方法。
现在,我想要的是下载图像时的进度条(点击圆圈)。一旦下载,它就会消失并且图像将加载。我将使用带有适配器的对象数组来填充网格视图。
您会以哪种方式使用 asynctask?
提前致谢。
I want to create a program that gets some images from a webpage, and shows them on a gridview. I dont know how many of them exactly. It could be from 20 to 30. Ill do it with asynctask, which i have allready used before and more or less know how it works. But i don't know which way use it this time.
For now, what i would like to get is a progressbar (circle clicking) while image is downloading. And once its downloaded, it would disappear and image will load. I will use an array of objects with an adapter, to fill the gridview.
Which way would you use the asynctask?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您查看 哈佛扩展 CS76 的第 6 讲。有一个
URLImageAdapter
和示例源代码,可以说明您正在寻找的内容。祝你好运
I would suggest you check out Lecture 6 of Harvard Extension CS76. There is a
URLImageAdapter
and example source code that does example what you are looking for.Best of luck
如果您想保存下载的图像并在将来重复使用它们,那么您必须查看 DownloadManager
要显示带有循环圈的对话框,请查看以下内容:如何使用 ProgressDialog
If you want to save downloaded images and reuse them in future then you must look DownloadManager
To display dialog with cycling circle, look this: howto use ProgressDialog