`

android listview中checkbox 的点击事件

 
阅读更多
我们经常遇见这样的事情,在listview的item中包含有textview和checkBox。我们既想获取listitem的点击事件,又想获取listitem中textview的点击事件和listitem中checkBox的点击事件,那么有没有办法实现呢?答案是肯定的,我们只需重新创建listview的适配器继承BaseAdpter就可以了。另外如果有checkBox或者imageview在内的话就必须设置它聚焦为false。
关键点:
1.listview的适配器要继承BaseAdpt
2.checkBox或者imageview在内的话就必须设置它聚焦为false。

<CheckBox
          android:layout_width="40px"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true"
          android:layout_marginLeft="140dp"
          android:focusable="false"//加这句的原因是因为checkBox的点击事件优先级高于listview的点击事件,所以要屏蔽之
          android:id="@+id/checkBox1"
>
</CheckBox>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics