-1

Is there a way to use both of setOnItemClickListener and OnclickListner in a ListView knowing that the List contains an ImageButton which will have setOnclickListner?

Edit

I use also OnItemLongClickListner so:

  1. I have something to do when I Click on the Item
  2. I have something to do when I Long Click on the Item
  3. and I have another thing to do when I click on the ImageButton that is in the Item

I hope that you can understand my problem and I know that I don't have a good English sorry

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Amine Choukri
  • 398
  • 2
  • 12
  • Of course, you can . By making `ImageButton`'s `onTouchEvent(...)` return `true`, you can get more help information after google-searching `android touch events`. wish you good luck. – jiar wang Jan 23 '18 at 01:18
  • I tried it but it doesn't work ... I have also `onItemLongClickListner` – Amine Choukri Jan 23 '18 at 12:09

1 Answers1

0

I solved The problem by adding :

android:descendantFocusability="blocksDescendants"

to the root list item element [such as the root layout].

Then within each ImageButton in the list item, I add:

android:focusableInTouchMode="true"

Reference

Amine Choukri
  • 398
  • 2
  • 12