ListView的Item包含checkBox的时候,出现onItemClick方法无效的情况,解决方法:
在item根布局设置descendantFocusability="blocksDescendants"后,还要设置checkBox的属性:onClick="false"和cliclable="false"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:descendantFocusability="blocksDescendants" android:orientation="vertical"> <CheckBox android:id="@+id/cb_pk_item" android:layout_width="match_parent" android:layout_height="38dp" android:background="@drawable/ic_bg_rect_normal" android:button="@null" android:clickable="false" android:gravity="center" android:onClick="false" android:text="1" android:textColor="@color/text_red" android:textSize="15sp" />