I have a ViewPager widget in my app with 5 fragments. I have 3 buttons for going to pages manually. For the 4 and 5 pages, i want user to be able to go only by pressing a button not by swipe. So i need to disable swipe events THROUGH them but not for others. Also when in page 4 or 5, swiping will be disabled completely and back button will appear on actionbar. How to achieve it?
List<Fragment> l = new ArrayList<>();
l.add(Fragment.instantiate(this, Osman.class.getName()));
l.add(Fragment.instantiate(this,Ahmet.class.getName()));
l.add(Fragment.instantiate(this,Kurik.class.getName()));
l.add(Fragment.instantiate(this,Sorok.class.getName()));
l.add(Fragment.instantiate(this,Yah.class.getName()));
SliderAdapter sa = new SliderAdapter(getSupportFragmentManager(),l);
vp = (ViewPager) findViewById(R.id.viewPager);
vp.setAdapter(sa);