Currently I have a dual pane layout for both landscape and portrait on a tablet.
Similar to say settings I have a single activity which loads a fragment into the left selection pane and then choices made in whatever right fragment is being shown result in further fragments being displayed into the right pane adding to the backstack all the way.
Now I can see that for some tablets it would make sense to have a single pane for portrait and a dual one for landscape. However, I would want the following behaviour:
A) If in landscape a fragment stack of depth N say is in the right pane then on an orientation change to portrait I would still want fragment N to be displayed and the stack to be maintained
B) Then navigating back from fragment N in portrait mode I eventually want to come back to the selection screen.
Now I can't figure out how to achieve this, ideas that I've come up with thus far are:
1) Have dual panes for both orientations but hide the left one on orientation change, would then need to reshow and hide right pane when stack is cleared
2) Rebuild the stack into the new containter, adding the selection fragment at the beginning on a switch to portrait
Neither, if they work, seem entirely satisfactory to me. Just wondering what the better/recommended way of doing this is.
Thanks in advance. Peter.
Edit 1
It should be mentioned that I understand that you can have have different layouts for portrait and landscape and am finishing up a large project with a dual pane layout for both portrait and landscape so OK on the lifecycle of an orientation change. I have also looked at the FragmentLayoutSupport
example but that doesn't maintain the data in the right pane on an orientation change to portrait, it shows the list again.