Android : How to Handle Custom ViewPager onInterceptTouchEvent

on Tuesday, November 11, 2014


Thanks for your time.


I have attempted to subclass ViewPager into InterceptPager which is throwing a casting error even though it is no different than its superclass. What is the correct way to gain access to onInterceptTouchEvent so as to prevent the ViewPager from scrolling and redirect the gesture flow of logic?


Here is the subclass for reference:



import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class InterceptPager extends ViewPager
{

public InterceptPager(Context context, AttributeSet attrs) {
super(context, attrs);
}

@Override
public boolean onInterceptTouchEvent( MotionEvent ev )
{
return false; // Sets all gestures to OFF
}
}

0 comments:

Post a Comment