androidlistviewonclicklistenerimagebuttononitemclicklistener

Can I use both of setOnItemClickListener and OnclickListner in a ListView


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


Solution

  • 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