在为行添加布局
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">