How to save fragment state while navigating with navigation component

后端 未结 6 1018
既然无缘
既然无缘 2021-01-02 14:24

I\'m trying to create a single activity app using android architecture components. I have a fragment A which has some textfields, when user pushes a button I navigate to fra

6条回答
  •  独厮守ぢ
    2021-01-02 14:53

    You need create ViewModels scoped to a Navigation Graph.

    Check this nice guide and you can keep your navigation component. Its very easy to implement and works for me!! https://medium.com/sprinthub/a-step-by-step-guide-on-how-to-use-nav-graph-scoped-viewmodels-cf82de4545ed

提交回复
热议问题