package com.wlz.adslibrary;

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

/**
 * Created by WaiLynnZaw on 9/25/16.
 */
public class NonScrollablePager extends ViewPager {

	private boolean isPagingEnabled;

	public NonScrollablePager(Context context) {
		super(context);
		this.isPagingEnabled = true;
	}

	public NonScrollablePager(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.isPagingEnabled = true;
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if (this.isPagingEnabled) {
			return super.onTouchEvent(event);
		}

		return false;
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent event) {
		if (this.isPagingEnabled) {
			return super.onInterceptTouchEvent(event);
		}

		return false;
	}

	public void setPagingEnabled(boolean b) {
		this.isPagingEnabled = b;
	}
}

Add custom view for view pager to disable swiping