How can I make a ListView touch-sensitive in its full width for clicking an item?
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"
and开发者_如何学Goroid: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.
精彩评论