cj1098
cj1098

Reputation: 1610

Handling onTouch events in android

So I have an autoScrolling scrollView in my class and I want to intercept the user onTouch event so that it stops the scrolling when they click on the scrollView. How will I implement this functionality? I know it has something to do with Overriding the onTouchEvent function, but when I Override this it doesn't work.

@Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_POINTER_1_DOWN:
            stopAutoScrolling();
        case MotionEvent.ACTION_POINTER_1_UP:
            startAutoScrolling();
        }
        return true;
    }

Upvotes: 0

Views: 631

Answers (1)

C Nick
C Nick

Reputation: 2520

I believe when you return true, you are saying you have handled the onTouchEvent. If you want the normal touch behavior to occur do something like:

return super.onTouchEvent(ev);

That way you call the native code which in your case would perform the scrolling as normal.

Upvotes: 1

Related Questions