Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable fling of a scrollView

I want to disable the fling gesture of a scrollview and it does not seem to be working.. I thought it would be as easy as creating a basic class that extends scrollview and @Overriding the onFling method. but eclipse is giving me an error to remove the @Override:

any ideas how to disable the fling

public class ScrollViewNoFling extends ScrollView {

    /**
     * @param context
     * @param attrs
     * @param defStyle
     */
    public ScrollViewNoFling(Context context) {

        super(context);
        // TODO Auto-generated constructor stub
    }
    public ScrollViewNoFling(Context context, AttributeSet attrs) {

        super(context, attrs);
        // TODO Auto-generated constructor stub
    }
    public ScrollViewNoFling(Context context, AttributeSet attrs, int defStyle) {

        super(context, attrs, defStyle);
        // TODO Auto-generated constructor stub
    }

   @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
    {
        return false;
    }

}
like image 520
erik Avatar asked Aug 29 '12 14:08

erik


1 Answers

I solved same problem with Override fling method. If you override fling method on your ScrollViewNoFling class and not call super.fling on this method, you gonna have not-fling-handled scrollView.

@Override
public void fling (int velocityY)
{
    /*Scroll view is no longer gonna handle scroll velocity.
     * super.fling(velocityY);
    */
}
like image 162
OzBoz Avatar answered Nov 03 '22 16:11

OzBoz