Android:ListView CheckBox 无意中被选中
我有一个 ListView,它布局在标题栏下方,布局在页脚栏上方。 ListView 的每一行都包含一个 LinearLayout,并排有一个 CheckBox 和 TextView。现在,当我一次可以显示更多行时,您当然可以向下或向上滚动。但是,一旦我向下或向上滚动,第一个和/或最后一个复选框就会被自动检查。我的手指离您选择复选框的位置很远。可能是什么原因造成的? 注意我在这里使用了代码: http://www.anddev.org/checkbox_text_list___extension_of_iconified_text_tutorial-t771.html
I have a ListView which is layout below a header bar and layout above a footer bar. Each row of the ListView contains a LinearLayout with a CheckBox and TextView side by side. Now, when I have more rows that can be shown at a time, you can of course scroll down or up. However, once I scroll down or up the first and / or last CheckBox is being checked automatically. My finger is nowhere near where you would select the check box. What could be causing this?
Note I used code here: http://www.anddev.org/checkbox_text_list___extension_of_iconified_text_tutorial-t771.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简要查看相关链接下显示的代码,我可以看到以下内容:
正如您所看到的,视图在滚动期间被重用,并且复选框状态是使用方法 setCheckBoxState 设置的。
然后在 CheckBoxifiedTextView 中,您可以找到:
在第 4 行中,有 setChecked(true) 硬编码,这可能会导致问题。
Looking briefly into code presented under link in question I can see the following:
As you can see the view is reused during scroll and checkbox state is set with method setCheckBoxState.
Then in CheckBoxifiedTextView you can find:
where in 4th line there is setChecked(true) hardcoded which might be causing the issue.