Good evening. I have three snippets, and I need to flip through them in ViewPager. And, so that when you start, the second fragment opens immediately, so that you have to flip backwards to the first one, and just swipe to the third fragment.
Wrote such code in the adapter, it turned out crap:
FragmentManager fm = getSupportFragmentManager(); mViewPager.setAdapter(new FragmentStatePagerAdapter(fm) { @Override public Fragment getItem(int position) { position = 2; if(position == 1){ return new FirstFragment(); } else if(position == 2) return new SecondFragment(); else return new ThirdFragment(); } @Override public int getCount() { return 3; } }); mViewPager - ViewPager announced earlier.
At the moment, it starts from the first fragment, or rather, the first position, but the second fragment is displayed. If you scroll further, the same second fragment is displayed. I do not know why.
What do you advise?