ListView的滚动后检查的项目不存在 [英] Listview's checked items not there after scrolling

查看:154
本文介绍了ListView的滚动后检查的项目不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已创建的TextView和复选框列表视图。然而滚动列表中向下(或向上)毕竟在列表中选中的项目得到选中。如何使选中的复选框保持其状态滚动后?

I have created a listview with textview and checkbox. However after scrolling the list down(or up) all the checked items in the list get unselected. How to make the checked checkboxes retain their state after scrolling?

推荐答案

的ListView回收每次滚动时的意见。这就是为什么的复选框不保留它们的状态。

ListView recycles the views every time it is scrolled. That's why the Check-boxes does not retain their states.

要完成你的任务:


  • 在存储阵列中的检查项目。

  • 当您单击列表视图的复选框,更改数组中的特定项目的值。

  • 在您的getView方法,检查或从阵列读取值取消选中的复选框。

这样,你的复选框将保留其状态。
我希望这是显而易见的。

That way your checkboxes will retain their states. I hope this is clear.

这篇关于ListView的滚动后检查的项目不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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