ListView onitemclick 不起作用
我有一个 ListView,其中包含一个复选框、一个图像视图、两个文本视图和一个按钮。问题是添加复选框和按钮后,ListView 的 onitemclick 事件没有响应。有人会建议解决该问题吗?
I have a ListView containing a checkbox, an imageview, two textviews and a button. The problem is after adding the checkbox and the button the onitemclick event of the ListView is not responding. Will anybody suggest a work around for the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以将复选框的
android:focusable
和android:focusableInTouchMode
属性设置为false
,并且列表的onItemClick
将称为。但您必须在onItemClick
中自行调用CheckBox#toggle()
。You can set both
android:focusable
andandroid:focusableInTouchMode
attributes of checkbox tofalse
andonItemClick
of the list will be called. But you'll have to callCheckBox#toggle()
yourself inonItemClick
.将 onlick 监听器添加到视图中。或复选框并手动处理。
Add an onlick listner to the view. or the checkbox and handle it manually.
当您在
listview
中使用checkbox
时,它会消耗您的点击操作并执行您的检查操作。您可以将点击侦听器放在文本视图、图像视图或按钮上。您还需要处理复选框。
When you use
checkbox
in yourlistview
then it consumes your click action and your check action will be performed.You can put click listener over textview, imageview or button. you also need to handle checkbox.