在Recyclerview中下载图像 [英] Downloading Image in Recyclerview

查看:96
本文介绍了在Recyclerview中下载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个回收站视图,其中Viewholder中有一个Imageview. 图像是通过适配器onBindViewHolder中的AsyncTask下载的.

I have a recycler view which has an Imageview in the Viewholder. The Image is downloaded via AsyncTask in the onBindViewHolder in the adapter.

问题是当我向下或向上滚动时,会调用onBindViewHolder来回收视图支架,并且图像会一次又一次地下载. 现在,我了解到Recyclerview应该是这样工作的. 因此,有人可以告诉我是否可以采取其他措施避免多次下载图片? 还是回到ListView更好?

The problem is when I scroll down or up, the onBindViewHolder is called for recycling the view holder and the Images are downloaded again and again. Now I understand that this is how Recyclerview is supposed to work. So can anyone tell me if anything can be done to avoid downloading the Images more than once? Or will it be better to move back to ListView?

推荐答案

使用毕加索并缓存图像.而且我猜默认是Picasso缓存图像.

Use Picasso and cache the image. And I guess Picasso Cache the image by default.

示例

Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);

这篇关于在Recyclerview中下载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆