0

I have a LinearLayout (a child view), that I need to be able to capture both clicks and drags. As a follow up: If drag, relay it to its parent; if click handle it. Does anyone know how to get that working?

Cote Mounyo
  • 13,817
  • 23
  • 66
  • 87
  • I think you're looking for `View.OnClickListener()` and `View.OnDragListener()` – Justin Jasmann Nov 27 '13 at 23:21
  • This question is basically a follow up to http://stackoverflow.com/questions/20227068/scrolling-listview-within-scrollview. So the parent is expecting a MotionEvent. But here I would have a DragEvent. I will look to see if a cast is possible. – Cote Mounyo Nov 27 '13 at 23:43

1 Answers1

0

Please use GestureDetector and here is the official tutorial for you.

http://developer.android.com/training/gestures/detector.html

You can bind detector to both parent and child view, and if the child is not interested in the event, return false in the callback to let the parent to handle it.

Robin
  • 10,052
  • 6
  • 31
  • 52