Search code examples
androidexpandablelistviewontouchlisteneronlongclicklistener

OnTouchEvent method overlap setOnItemLongClickListener in ExpandableListView


I created a custom expandableListView (extends of ExpandableListView). Now I need to override the OnTouchEvent(MotionEvent event) method. But, I need use setOnItemLongClickListener for a child item too. But it does not work when onTouchEvent is overridden. When I use onChildItemListener too, then it works fine. Why does it happen, and how to fix it?


Solution

  • This happens because the "normal" OnTouchEvent(MotionEvent event) calls the required events of the children. Call super.OnTouchEvent(event); to fix it.