android获取被点击ID,android – 如何从ListView获取行的行ID,其中包含可点击的项目?...

在为行添加布局

XML的按钮之前,在单击列表项时,在回调onListItemClick()中返回行ID.现在我在列表行布局中添加了一个按钮,此回调不再起作用.我读到这是正常的.我已经能够通过在我的列表行的布局XML文件中包含这种东西来获取文本和新按钮来引用新的回调:

android:onClick="newCallBackFunctionName"/>

问题是我似乎无法找到一种方法来检索与按下的特定按钮所在的列表项对应的行ID号.在onListItemClick()的情况下,它作为回调的一部分传递,但在上面的例子中,只有被点击的View对象被传递回回调newCallBackFunctionName.我该怎么办?

*编辑:我的列表由SimpleCursorAdaptor填充,以防重要.

*编辑:我的列表和列表行XML布局如下:

列表:

xmlns:android="http://schemas.android.com/apk/res/android"

style="@style/basic_linear_layout_v1">

android:id="@+id/category_selection_page_name"

style="@style/page_heading_v1"/>

android:id="@id/android:list"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_weight="1"

android:drawSelectorOnTop="false"/>

android:id="@id/android:empty"

style="@style/problem_text_v1"

android:text="@string/search_list_empty" />

android:id="@+id/select_category_button"

android:textSize="20sp"

android:layout_weight="10"

android:layout_height="wrap_content"

android:layout_width="fill_parent"

android:onClick="reload"/>

行:

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:orientation="horizontal">

android:layout_weight="1"

android:layout_gravity="left"

android:focusable="true"

android:clickable="true"/>

android:layout_width="wrap_content"

android:layout_height="fill_parent"

android:layout_gravity="right">

android:text="..."

android:id="@+id/subcategories_button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:focusable="true"

android:onClick="onSubcategoryButtonClick">

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值