I have application titles fragment and contents fragment on the screen. When the user clicks on the item in titles fragment the according fragment is created and inserted to a frame and the selected title is highlighted in titles fragment.
Transaction is done with fragment.addToBackStack()
, so when the user clicks the BACK
key, the previous fragment is restored and inserted in the frame.
What is the best solution to restore view state when transaction manager restores fragments?
The problem is that I should highlight previous fragment name in titles fragment and I should know what fragment it is. I resolved it by storing view state in my own stack: when fragment is created and restoring on changing transaction backstack using transaction manager listener.
But this doesn't seem like the correct solution.