I use ListView to display multiple items. My row.xml as below:
<TextView android:text="text" android:id="@+id/tvViewRow" android:layout_width="wrap_content" android:layout_height="wrap_content"> </TextView> <Button android:text="Click me!" android:id="@+id/BtnToClick" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="myClick"> </Button>
And I define myClick in action, as shown below:
public void myClick (View v) { LinearLayout vwParentRow = (LinearLayout)v.getParent();
How to find out the position that you need to click on the button? Position means the same as the onListItemClick method.
@Override protected void onListItemClick(ListView l, View v, int position, long id) { }
android listview
brian
source share