0

In my app, I have a listview and this listview contains two buttons.

If I click on button 1 I need to move Activity-A from my Listview If I click on button 2 I need to move Activity-B from my Listview If I click on listview I need to move Activity-c from my Listview

But my main problem is when I click on buttons listview onitem click action is performing.

How can I make separate actions for those items what I said above with some code?

Bilesh Ganguly
  • 3,792
  • 3
  • 36
  • 58
AbhiRam
  • 2,033
  • 7
  • 41
  • 94
  • Are the buttons outside the ListView or are they in each row/each item? In the former case, you need to define separate OnClickListeners for those buttons. If the latter case, you need to detect which view specifically was clicked in OnItemClickListener. – shobhik Aug 03 '16 at 03:25
  • buttons added each row of listview @shobhik – AbhiRam Aug 03 '16 at 03:26
  • can u explain me with soem code – AbhiRam Aug 03 '16 at 03:28

1 Answers1

0

Thanks for the additional information! Based on that, you will need to define separate OnClickListeners for each button. The way to do that is to define your own Adapter, and in the getView(), set these click listeners.

A good example is in another answer here.

Community
  • 1
  • 1
shobhik
  • 200
  • 5
  • for listview row i have to make seperate action? – AbhiRam Aug 03 '16 at 03:34
  • Yes. By default, the click handler for OnItemClickListener treats clicks anywhere in a row as one action. The answer I linked to overrides that handling and makes the ListView detect which subview inside your row was getting clicked, if that makes any sense. – shobhik Aug 03 '16 at 03:56