0

As I understand, ViewPager will preload fragments' views so that it can speed things up. I am looking for another widget that does the same thing, but users cannot swipe to switch between pages. I know one option would be to disable swipe on ViewPager but is there any other option?

Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154
skynova2070
  • 29
  • 1
  • 3
  • Possible duplicate of [How do disable paging by swiping with finger in ViewPager but still be able to swipe programmatically?](http://stackoverflow.com/questions/9650265/how-do-disable-paging-by-swiping-with-finger-in-viewpager-but-still-be-able-to-s) – N J Jun 05 '16 at 02:01

1 Answers1

0

Extend the ViewPager and override the onTouchEvent method.

public class ViewPagerNoScroll extends ViewPager {
    public ViewPagerNoScroll(Context context) {
        super(context);
    }

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

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return false;
    }
}
damjanh
  • 143
  • 4