I have a list of fragments implemented together with FragmentStatePagerAdapter. I must replace the current fragment with a new one each time the button don't like will be clicked. The problem with the ViewPager. In my case the ViewPager scroll exactly list.size() -1 times smoothly, All other scrolling disable the smoothly scrolling.
doNotLike.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fragmentList.set(viewPager.getCurrentItem(), alternativeList.get(viewPager.getCurrentItem()));
viewPagerAdapter.notifyDataSetChanged();
viewPager.setCurrentItem(currentPos + 1, true);
}
});
I have no idea why the smoothly scrolling is so limited with fragmentList-size and how can I turn off this behaviour.