Alex Bichel
Alex Bichel

Reputation: 85

Android : How to identify button click in a Listview having more than one button

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.

Upvotes: 1

Views: 340

Answers (2)

Vipul J
Vipul J

Reputation: 6691

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

Upvotes: 1

bakriOnFire
bakriOnFire

Reputation: 2681

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().

Upvotes: 2

Related Questions