문제

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

How can I do that? This is my layout XML:

<?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>
도움이 되었습니까?

해결책

That is the default behaviour - are you sure your ListView and custom row layouts, if you're using some, are set to width="fill_parent"? If they are already on width="fill_parent", post up your XML and/or code so we can see what's wrong.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top