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.
精彩评论