Android Navigation Drawer Fragment State

后端 未结 4 1976
北海茫月
北海茫月 2020-12-14 20:56

I\'m currently utilizing the Navigation Drawer for my Android APP. In my first fragment, I\'ve a fragment that loads data using Facebook\'s Graph API. Thus, when my App is f

4条回答
  •  无人及你
    2020-12-14 21:22

    The second option is to start with the example of navigationDrawer that Android SDK offers. I selected that template of activity when creating the project and almost all the code of my previous answer is produced automatically.

    If you want to keep the fragments after device rotation or similars it is a different thing, you need then to retain the fragments. If not, you just need to save the new instance of the fragment in a variable and check if it is null to create a new one or use the old one.

提交回复
热议问题