ListView的内容加密的滚动 [英] ListView's contents scrambled on scroll

查看:158
本文介绍了ListView的内容加密的滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有不同的,这就使我的ListView的问题。我把它们放进一个ArrayList和使用自定义ArrayAdapter挂钩到ListView,所以之前我不相信这里面就有一个问题,我已经做了。最初,列表似乎有正确的顺序的作品,但我会向下滚动列表,然后将内容将在不正确的顺序加载。我再回到向上滚动,一切都混乱。有没有人遇到此之前?

So I am having a problem with the different pieces of that make up my ListView. I put them into an ArrayList and use a custom ArrayAdapter to hook up to the ListView, which I have done before so I don't believe there is a problem there. Initially the list seems to have the pieces in the correct order, but then I will scroll down the list and the contents will then load in incorrect order. I then scroll back up and everything is jumbled. Has anyone run into this before?

谢谢
-Jake

Thanks -Jake

推荐答案

是你的问题涉及到了List重用每一行的观点的事实。所以说,你的列表可以看到5个项目,但你的ListAdapter它有15个的东西。机器人将创建行视图的5 + 1的实例,而不是15一列表中的+1的每一行,用于当可以看到的顶部和底部的一半。当行被移出可见区域的列表将回收该视图实例另一行,而不是创建一个新的。如果不正确,每次重置所有用户界面组件,你会得到从其他行器物显示出来。你必须确保你每次从绑定的对象你的数据在你的数组列表你每一次设定各个领域的看法。

Yes your problem is related to the fact that List reuses the views for each row. So say your list can see 5 items, but your ListAdapter has 15 things in it. Android will create 5 + 1 instances of your row view instead of 15. One for each row in the list + 1 for when half of the top and bottom can be seen. When a row is moved out of the visible area the List will recycle that view instance for another row instead of creating a new one. If you don't properly reset all of the user interface components every time you'll get artifacts from other rows showing up. You must make sure that every time you bind your data from the objects in your array list to the view you set every field every time.

有关这个更好的说明请参见

For a better description of this see

<一个href=\"http://www.youtube.com/watch?v=N6YdwzAvwOA&feature=related\">http://www.youtube.com/watch?v=N6YdwzAvwOA&feature=related

这篇关于ListView的内容加密的滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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