Ok this basically what I'm trying to accomplish: I have a FragmentStatePagerAdapter and want occasionally to disable the swipe functionality and use buttons to go forward/backward.
A snipped from my code in MyFragmentStatePagerAdapter extends FragmentStatePagerAdapter : (works fine with swipe, just for your orientiation)
public Fragment getItem(int position) {
Item item = items.get(position/2);
if (position%2 == 0) return new MyFragmentA(item, param1);
if (position%2 == 1) return new MyFragmentB(item, param1);
return null;
}
Any suggestions? I just need to deactivate swipe and use 2 buttons...
thx
I fixed the Problem:
I didn't need to tamper with the Adapter (FragmentStatePagerAdapter). The ViewPager has a Method setCurrentItem:
https://developer.android.com/reference/android/support/v4/view/ViewPager.html#setCurrentItem(int)