- <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初始的时候没有获取焦点。
本文介绍了解决Android开发中Checkbox与ListView焦点冲突的问题。通过设置Checkbox的可聚焦属性为false,确保了ListView能正常获取焦点,避免了点击事件的优先级问题。
8191

被折叠的 条评论
为什么被折叠?



