I have a FiewFlipper
that has ListViews as children. I have looked for a way to intercept touch events for a GestureDetector
before they reach the children - a method to globally intercept touch events over the ViewFlipper.
Extending FiewFlipper and implementing onInterceptTouchEvent (MotionEvent ev)
seemed to be the solution. This works well for most children. However, when the listview begins to scroll, onInterceptTouchEvent stop receiving the events.
I know it's possible to set each listview's OnTouchListener, but this ruin开发者_开发百科s simple hierarchy I'm attempting to create.
Hmm. I once had an activity with a single listview, where I re-populated the adapter as a result of fling gestures. I did it by implementing the dispatchTouchEvent method of the activity:
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
super.dispatchTouchEvent(ev);
return gestureDetector.onTouchEvent(ev);
}
The listview still received the normal events, but my gestureDectector got to taste them too. Perhaps a similar approach will work for you?
As commented by adamp, this behaviour is intentional and does not need to be fought. I applied the gesture listener to the children elements.
精彩评论