Question

How can creat a SwipeView that starts with the layout of an intermediary fragment from the collection instead of the first?

e.g. I have a list of 10 emails of the same person and I click the 3th most recent to show the content in another Activity. After that, I want to swipe to left and go to the 2nd most recent and swipe to right and go to 4th most recent.

I am following the tutorial but it seems that the first layout displayed to the user always will correspond to first position from the collection of Fragments. In my example the user will just be able to swipe to righ and see the emails from 3 to 10.

Was it helpful?

Solution

You can use ViewPager's setCurrentItem() method to specify the initially shown fragment by index, although you should only do this only on the first initialization (i.e. when savedInstanceState is null) so that the ViewPager can persist it's selection through Activity restarts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top