At first start the app will have to do some initial configuration, and so I need to load pages and slide it based on the user decision on a page. So I would like to set and to slide to left the correct page after that decision with animation. The visual step indicator can even change... Everything should be dynamic as following:
But ViewPager always loads at least the next page itself after few moments (setOffscreenPageLimit(0)
isn't allowed); Actually when user chooses an option from the setup fragment, the slide animation runs through all middle pages and they are visible during animation because I use mIndicator.setCurrentItem(5, true);
I was able to disable the gesture slide but the arc animation doesn't work. I could set mIndicator.setCurrentItem(5, false);
but I still want the slide animation after user clicks the buttons to reach the appropriate page.
The Fragment setup has an Interface listener that the Activity implements. The listeners are called from the buttons and the implemenation looks like:
...
@Override
public void onRestoreLocal() {
//The indicator contains ViewPager and it switches the page as well.
mIndicator.setCurrentItem(5, true);
}
...
public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
...
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment.
Log.d(TAG, "getItem position="+position);
switch (position) {
case 0:
return PlaceholderFragment.newInstance(R.layout.setup_fragment_1, position);
case 1:
return PlaceholderFragment.newInstance(R.layout.setup_fragment_2, position);
case 2:
return SetupChoiceFragment.newInstance();
case 3:
return SetupCreateFragment.newInstance();
case 4:
return SetupImportFragment.newInstance();
case 5:
return SetupRestoreFragment.newInstance();
}
return null;
}
...
}
- Should I set the number of pages to 6 in order to jump to the page chosen? But how to maintain Slide Animation and PageIndicator always =4!
- How to avoid the automatic loading of the next slide or it doesn't matter?
- Should I stick to use the ViewPager or manage the Fragment navigation myself setting the custom sliding animation (with next/back) on the FragmentTransaction without using FragmentStatePagerAdapter and managing the backstack while going back? or what others component exists for a wizard configuration?
Also, how to go back always on page#3 with gesture animation slide blocking right manual gesture?