How can I make a ListView touch in its full width to click on an item?

I have a ListView in a ListActivity filled with strings. However, only the text part of the list item is clickable, and when it is clicked, only the text part is highlighted (orange on a black background). I would like to make the full line clickable, and when it is selected, the full line should be marked as selected.

How can i do this? This is my XML layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/TextViewLocationMode"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="-" >
    </TextView>

    <TextView
        android:id="@+id/TextViewStatus"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Statustekst" >
    </TextView>

    <ListView
        android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:choiceMode="singleChoice"
        android:clickable="true"
        android:fadeScrollbars="true"
        android:isScrollContainer="true"
        android:longClickable="true" >
    </ListView>

</LinearLayout>
+3
source share
1 answer

- , ListView , , width = "fill_parent"? = "fill_parent", XML / , , .

+8

Source: https://habr.com/ru/post/1740504/


All Articles