- <CheckBox
- android:id="@+id/cb"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:focusable="false"
- android:focusableInTouchMode="false"
- android:clickable="false"
- android:checkMark="?android:attr/listChoiceIndicatorMultiple"/>
- android:focusable="false"
- android:focusableInTouchMode="false"
- android:clickable="false"
这三句很重要,如果不加就会出现错误。
由于checkbox的点击事件优先级比listview的高,所以要在checkbox中添加android:focusable="false",使得checkbox初始的时候没有获取焦点。