ListView的ImageView的负荷相同的图片 [英] ListView ImageView load same pictures

查看:86
本文介绍了ListView的ImageView的负荷相同的图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的问题,我ListViewAdapter。

i have a big problem with my ListViewAdapter.

我的列表视图显示在同一时间2 entrys。每个条目都应该从我的服务器不同的画面。
第一和第二entrys工作正常,但如果我向下滚动,接下来entrys将具有相同的图片。

My listview shows 2 entrys at the same time. Each entry should get a different picture from my server. The first and the second entrys working fine, but if i'm scrolling down, the next entrys will have the same pictures.

我的code是这样的:

My Code looks like this:

if (viewHolder.imgPic != null) {
    String strUrl = mainUrl+list.get(position).getUrl();
    new ImageDownload(viewHolder.imgPic).execute(strUrl);
}

我检查的观点,只是做它,如果它是空。

I'm checking the view and just doing it, if it's null.

有人能帮助我吗?
谢谢

Can someone help me? Thanks

推荐答案

从你的问题,我可以假设你不知道的的ListView recycling mechanisem

from your question I can assume that you don't know about the ListView recycling mechanisem

基本上,查看该不再可见(用户滚动它从视线离开后)它被再循环到需要显示显示新项。这是在 convertView 参数 getView()方法...

basically, view that that not visible anymore (after user scrolled it away from sight) it been recycled to displayed new item that need to shown. that's the convertView parameter at the getView() method...

也许你看到同样的图像,因为回收的观点保持在相同的图像。

probably you are see the same image because the recycled view stays with the same image..

也有异步任务(你ImageDownload类),可以完成它时执行已经回收启动该请求中的原始项的问题。

also there is the issue of the asynchronous task (your ImageDownload class) that can finish it execute when the original item that started the request already been recycled.

我建议你挖为杓因为你可以了解所有关于的ListView - 这是最复杂和最重要的UI组件之一。看完我挂你的职位是一个良好的开端。

I recommend you to "dig" as dipper as you can to understand all about ListView - this is one of the most complex and important UI component. reading the post I linked you is a good start.

也这段视频是很重要的:

also this video is very important:

http://www.youtube.com/watch?v=wDBM6wVEO70

这篇关于ListView的ImageView的负荷相同的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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