Search code examples
javaandroidandroid-fragmentsandroid-lifecycle

Restore the UI-state after recreating the fragment


How can I restore the UI status of my Fragment-A after I have replaced it with Fragment-B and then call Fragment-A again?


Solution

  • You could use SharedViewModel between these two fragments and store the state there.

    Share data between fragments with SharedViewModel