Я новичок в Android. У меня есть ListActivity, которые включают ListView. Элемент в ListView настроен. Xml-макет:Как слушать каждую кнопку в ListView в Android
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:textSize="22sp" ></TextView>
<TextView
android:id="@+id/item2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingTop="5dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@null"
android:onClick="favoriteOnClick"
android:src="@drawable/favorite_logo" />
</RelativeLayout>
</LinearLayout>
У этого есть изображениеButton.
Когда кнопка была нажата. Я хочу получить, какая кнопка была нажата (значит, мне нужно получить, какой элемент ListView).
и будет получить идентификатор элемента, отображаемый в ListView? Разве это – KOTIOS
Если вы хотите использовать 'метод favoriteOnClick' для получения ImageButton нажмите затем в GetView() из пользовательского адаптера просто установить тег из ImageButton с позицией Элемент списка затем извлекает его в 'favoriteOnClick'using' getTag() '. – user370305