【问题标题】:how to remove the focus of checkbox in listview in android如何在android的listview中删除复选框的焦点
【发布时间】:2016-08-16 23:40:54
【问题描述】:

我正在尝试有一个ListView,其中每一行都有一些文本和一个checkbox。当我单击列表视图时,它将选中或取消选中已完成的检查,但我想禁用 checkbox 的焦点,即优先列出项目而不是 checkbox 这里是 checkbox 和 @987654326 的代码@。

<CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/checkbox"
        android:layout_margin="@dimen/login_field_margin"
        android:layout_alignParentRight="true"
        android:focusable="false"
        android:selectAllOnFocus="false"
        android:focusableInTouchMode="false"
        />

<ListView android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:id="@id/listView"
        android:dividerHeight="0.25dp"
        android:focusable="true"
        android:divider="@color/colorDarkgrey"
        android:background="@color/colorwhite"> </ListView>

【问题讨论】:

    标签: android listview checkbox


    【解决方案1】:

    在您的项目布局 xml 中,您可以在根视图中添加此 attr

    android:descendantFocusability="blocksDescendants"
    

    试试这个。 here 是这个属性的 api。

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="blocksDescendants"
        android:orientation="vertical" >
        <CheckBox
        ...
        ></CheckBox>
    </LinearLayout>
    

    您的项目布局应该是这样的。

    【讨论】:

    • 你能给我提供任何样品吗
    • 请提供一些例子
    猜你喜欢
    • 1970-01-01
    • 2017-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-03
    • 2013-02-19
    • 2015-07-12
    • 2013-02-15
    相关资源
    最近更新 更多