Android ListView中CheckBox取值问题

来源:互联网 发布:网络女神雅典娜 种子 编辑:程序博客网 时间:2024/04/27 20:49

1 设置布局文件中checkbox

   <CheckBox        android:id="@+id/tv_select"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_margin="10dp"        android:checked="false"        android:focusable="false"        />

注意:需要设置父控件属性为:

android:descendantFocusability="beforeDescendants"

属性的值有三种:

    beforeDescendants:viewgroup会优先其子类控件而获取到焦点    afterDescendants:viewgroup只有当其子类控件不需要获取焦点时才获取焦点    blocksDescendants:viewgroup会覆盖子类控件而直接获得焦点

在item 里的父布局中加入android:descendantFocusability=”beforeDescendants”

0 0