1

My custom Listview has more than one button, how can I identify which button has been clicked ? I want to do different things on action of different buttons.

Alex Bichel
  • 85
  • 1
  • 2
  • 5

2 Answers2

2

In custom adapder of your ListView you must be creating objects of each button in its getView() method.

Just set the onClickListener on the buttons and perform the action on each buttons in its onClick().

bakriOnFire
  • 2,685
  • 1
  • 15
  • 27
1

Create local variables for buttons inside getview method and set onClickListener for each button in a row.

Also have a look at this -: 2 Buttons in ListView in android

Community
  • 1
  • 1
Vipul J
  • 6,641
  • 9
  • 46
  • 61