开发者

ViewFlipper switching ListViews via Gesture

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜