Code example for ViewPager

Methods: setAdapter

0
    } 
 
    @Override 
    public void setAdapter(PagerAdapter adapter) {
        if (adapter instanceof ValidationViewPagerAdapter) {
            super.setAdapter(adapter);
        } else { 
            throw new IllegalArgumentException("ValidationViewPagerAdapter required");
        } 
    } 
 
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        return canSlide() && super.onTouchEvent(ev);
    } 
 
    private boolean canSlide() { 
        final ValidationViewPagerAdapter adapter = (ValidationViewPagerAdapter) getAdapter();
        return adapter.isFragmentValid(getCurrentItem());
    }