开发者

I'd like to click anywhere (blank area) in a list view

开发者 https://www.devze.com 2023-02-01 00:38 出处:网络
As a new android programmer I have my obligatory todo app running.It is acceptable for Christmas shopping, but I\'d really like to make the whole list-item row clickable.Right now I have to tap the te

As a new android programmer I have my obligatory todo app running. It is acceptable for Christmas shopping, but I'd really like to make the whole list-item row clickable. Right now I have to tap the text. The shorter the item the harder to hit.

My main activity extends ListActivity. I use a subclass of ResourceCursorAdapter for the list itself. My layout looks like this (thanks!):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/todo_row"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.a开发者_Go百科ndroid.com/apk/res/android">

<CheckBox android:text=""
        android:id="@+id/todo_checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:focusable="false"
        android:checked="false"
        ></CheckBox>

<TextView android:text=""
        android:id="@+id/todo_text"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        ></TextView>

</LinearLayout>


Tapping anywhere in the row is the default behavior of a listView. How are you setting up your onClick listeners? You should use the onItemClickListener.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号