复选框在ListView选中状态 [英] CheckBox checked state in a ListView

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

问题描述

我使用的是复选框一个ListView,但由于大多数人都知道,当你摇下滚动,选中复选框取消选中得到你卷起回滚动。所以我一直在读,我发现,你可以(使用getView)可换股债券,以getView的位置参数的id保存复选框状态过关!

I'm using a ListView with CheckBox, but as most of you know, when you roll down the scroll, a checked CheckBox gets unchecked as you roll up back the scroll. So i've been reading and i found out that you can pass (using getView) the id of the CB to the position parameter of getView to save the CheckBox state!

但我不能SimpleCursorAdapter使用getView,可以吗?因为我使用bindView!

But i can't use getView with SimpleCursorAdapter, can i? Because i'm using bindView!

感谢

推荐答案

正在发生的事情是循环利用。 7行适应你的屏幕,当你向下滚动,顶一个被回收在底部的新的。你应该做的是保存的复选框的状态。

What is happening is recycling. 7 rows fit in your screen and when you scroll down, the top one is being recycled for the new one at the bottom. What you should do is to save the states of the checkboxes.

下面是一个很好的解决了类似的问题:

Here is a good solution to a similar problem:

https://github.com/commonsguy/cw-android/树/主/ FancyLists / RateList

这篇关于复选框在ListView选中状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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