1

If I have a fragment containing a ListView where each row is a series of clickable elements (say, 3 buttons) filling all available space on the row, can I possibly have a long click callback for the entire row?

I want the user to be able to click on any of the three elements with a quick click but the long click should select the entire row/entry.

I have tried hooking up the ListView with the setOnItemLongClickListener while setting android:longClickable on the individual elements in the layout, but I never see the callback get hit for the long press.

Is this feasible? Do I need to have each element listen for the long click and push it back to the ListView somehow?

Jeff L.
  • 226
  • 1
  • 3
  • 13
  • This related question may provide the answer see http://stackoverflow.com/questions/8846707/how-to-implement-a-long-click-listener-on-a-listview – BenC Aug 09 '14 at 23:42
  • It is similar, but it did not answer my question. I am already doing what they said there. – Jeff L. Aug 09 '14 at 23:47
  • I think you have to apply individual button long click instead entire row which is not possible becz your child have already implement click listener so try to implement individual button long click listener. – Haresh Chhelana Aug 10 '14 at 05:51

2 Answers2

1

Since these three elements(Button) filling up entire space of the , it is difficult to set long click listener for that row...

so good idea is set one same long click listener for these elements rather than row, if they don't have any long click events..

thank you

Sam
  • 4,046
  • 8
  • 31
  • 47
  • My expectation was that the long click would "pass through", but I'm guessing that's not the case. – Jeff L. Aug 10 '14 at 03:29
  • I ended up adding long click listeners to each element in the row and just returning "false" on each of them, which does cause them to pass through to the parent fragment. – Jeff L. Aug 12 '14 at 03:17
0

Put longclicklistener on list view and when that is performed some boolean make true and in your 3elements clicklisteners check if it is false than do other commands.

Vahe Muradyan
  • 1,115
  • 1
  • 11
  • 22