Saturday, September 8, 2012

[android-developers] Re: onInterceptTouchEvent and Gesture detector

It's too late, but it maybe useful for others so I post my solution here:

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        mGestureDetector.onTouchEvent(event);
        return true;
    }
 
    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        return mGestureDetector.onTouchEvent(event);
    }

Regards,

On Friday, February 17, 2012 9:24:21 PM UTC+7, harvinder wrote:
The View:
I have a Custom ViewGroup that handles gestures from users. I am overriding onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent me)
{
return _gestureDetector.onTouchEvent(me);
}
It also have some other views as its children.


Problem:
I am correctly able to handle all the gestures in my Custom ViewGroup. Hoever, if I add a click listener on any of the children, gesture detection stops.

I understand that I am suppose to play with onInterceptTouchEvent method. However, it seems like I have to handle raw events in this method, which make me very uncomfortable given that GestureDetector handles all these low level events.


I would like to not intercept the click event and pass that on to the children but handle the rest using gesture detector.

thanks
harvinder

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment