Search code examples
androidlistviewandroid-togglebutton

setOnItemLongClickListener not working after a togglebutton is placed in ListView


I am trying to implement a Custom adapter for ListView where I have two TextViews and a ToggleButton. Before the togglebutton I was able to use setOnItemLongClickListener which I can not now and I know that focus is on togglebutton so is the issue. However I want two operation work simultaneously so I have tried to use:

 android:longClickable="true"
 android:descendantFocusability="blocksDescendants" 

Then I tried to use

listView1.setLongClickable(true);

Tried to return true in onItemLongClick

However, these things are not working. How can I handle this?


Solution

  • Give this Attribute to Adapter Layout

    android:descendantFocusability="blocksDescendants"