dimanche 18 janvier 2015

Android CheckBox in ListView get focus

I have a ListView, each item has a TextView and a CheckBox. I want that the user can select each item by pressing the row. But the checkbox also gets focus. I want to remove the focus from the checkbox when a list item is clicked.



<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height"
android:orientation="horizontal">

<TextView
android:id="@android:id/text1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>

<CheckBox
android:id="@android:id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:clickable="false"
android:focusable="false"/>


Screenshots when the list item is pressed:


enter image description here


enter image description here





Aucun commentaire:

Enregistrer un commentaire