I have a list view with 2 buttons on each row.
I am using a cursoradpater to populate the list.
I am also using the view holder pattern on newview() bindview().
My questions are:
where do i put the clicklisteners for the buttons knowing that the action for the button is different from the action of the list item itself?
Do i keep the onListItemClick ?
You do not need the
onListItemClickYou can try binding for each of your button an event in the adapter
but probably this won’t work on the list item, so you need a new aproach as is this described in the button documentation.
However, instead of applying an OnClickListener to the button in your activity, you can assign a method to your button in the XML layout, using the android:onClick attribute. For example:
Now, when a user clicks the button, the Android system calls the activity’s selfDestruct(View) method. In order for this to work, the method must be public and accept a View as its only parameter. For example:
The View passed into the method is a reference to the widget that was clicked.