How to disable scrollView scroll

I want to disable fling scrollview gestures and it doesn't seem to work. I thought it would be as simple as creating a base class that extends the scrollview and @ Overridingmethod onFling. but eclipse gives me an error to remove @Override:

any ideas on how to disable startup

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;
    }

}
+5
source share
3 answers

I solved the same problem with the Override fling method. If you override the fling method to your ScrollViewNoFling class and do not call super.fling on this method, you will not have scrollable scroll.

@Override
public void fling (int velocityY)
{
    /*Scroll view is no longer gonna handle scroll velocity.
     * super.fling(velocityY);
    */
}
+12
source

I think it should be a run, not onFling. Please refer to the official documentation.

0

fling() onFling() .

According to the documentation for onFling () :

Returns

true if the event is consumed, else false

If you want to catch an event and do nothing, return true. Otherwise, the event will be passed to another method / class to try to handle it.

0
source

All Articles