Separate Back Stack for each tab in Android using Fragments

后端 未结 12 1015
南旧
南旧 2020-11-22 14:51

I\'m trying to implement tabs for navigation in an Android app. Since TabActivity and ActivityGroup are deprecated I would like to implement it using Fragments instead.

12条回答
  •  执念已碎
    2020-11-22 15:24

    I'd like to suggest my own solution in case somebody is looking and want to try and choose the best one for his/her needs.

    https://github.com/drusak/tabactivity

    The purpose of creating the library is quite banal - implement it like iPhone.

    The main advantages:

    • use android.support.design library with TabLayout;
    • each tab has its own stack using FragmentManager (without saving fragments' references);
    • support for deep linking (when you need to open specific tab and specific fragment's level in it);
    • saving / restoring states of tabs;
    • adaptive lifecycle methods of fragments in tabs;
    • quite easy to implement for your needs.

提交回复
热议问题