I have a class which reads an XML file to create several screens in a Horizontal Page flipper.
However, the view content can be different when changing from portrait to landscape or back.
I’d like to save the current selected page so whenever I swap my screen it uses that value again to build up the new orientation screen.
I use a HorizontalPager class which can retrieve current page by getCurrentScreen() (returns an integer) and one to set the page setCurrentScreen(int currentScreen, boolean animate)
So whenever I switch screens, the current page should still be selected, instead of creating the whole thing again and starting from page 1 (0 in the array).
I just slept over my question and solved it myself 🙂
What I did is:
I made a method called setPager(int pager) that sets my static in Pager to the current page.
This method is called from the HorizontalPager class whenever a screen is flipped.
Every time the screen flips, the onCreate() is called, and my HorizontalPager will be set to the value my static int has with a method setPager(int pager).