我想任意位置单击(空白区域)的列表视图 [英] I'd like to click anywhere (blank area) in a list view
问题描述
作为一个新的Android程序员,我有我义不容辞待办事项应用程序的运行。这是圣诞购物可以接受的,但我真的很想让整个列表项排点击。现在我有挖掘的文字。较短的项目更难打了。
我的主要活动扩展ListActivity。我用ResourceCursorAdapter的子类的列表本身。我的布局看起来像这样(谢谢!):
<?XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout机器人:ID =@ + ID / todo_row
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
的xmlns:机器人=http://schemas.android.com/apk/res/android><复选框的android:文本=
机器人:ID =@ + ID / todo_checkbox
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:可聚焦=假
安卓:检查=假
>< /复选框><的TextView的android:文本=
机器人:ID =@ + ID / todo_text
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
>< / TextView的>< / LinearLayout中>
该行中的任意攻丝是ListView的默认行为。你是如何设置你的onClick监听器?您应该使用 onItemClickListener 。
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.android.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.
这篇关于我想任意位置单击(空白区域)的列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!