Skip to content Skip to sidebar Skip to footer

Simpleongesturelistener Not Working For Scrollview

I have a screen where I have a header, a TextView inside a ScrollView and footer. I have to use ScrollView as the Text in the TextView can be long also. Now when I am using SimpleO

Solution 1:

I got the solution for this issu

Add following method in the your Activity class

@OverridepublicbooleandispatchTouchEvent(MotionEvent ev){
    super.dispatchTouchEvent(ev);
    return gestureScanner.onTouchEvent(ev);
} 

As suggested in the below link:

http://groups.google.com/group/android-developers/browse_thread/thread/9fdfb03d0959e299

Solution 2:

You have to create a custom ScrollView object and override it's onTouchEvents to also check for your gestures. It's demonstrated in the following code.

publicclassGestureScrollViewextendsScrollView {
    GestureDetector myGesture;

    publicGestureScrollView(Context context, GestureDetector gest) {
        super(context);
        myGesture = gest;
    }

    publicGestureScrollView(Context context) {
        super(context);
    }

    publicGestureScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @OverridepublicbooleanonTouchEvent(MotionEvent ev) {
        if (myGesture.onTouchEvent(ev))
            returntrue;
        elsereturnsuper.onTouchEvent(ev);
    }

    @OverridepublicbooleanonInterceptTouchEvent(MotionEvent ev) {
        if (myGesture.onTouchEvent(ev))
            returntrue;
        elsereturnsuper.onInterceptTouchEvent(ev);
        }
    }

Let me know if you run into any issues. :)

-Zaid

Post a Comment for "Simpleongesturelistener Not Working For Scrollview"