Fragment view in ViewPager is not restored when resuming

前端 未结 6 1426
独厮守ぢ
独厮守ぢ 2020-11-30 12:23

I have ActionBar Tabs setup. It consists of 4 tabs. Everything is fine until I navigate away from TabbedFragment and returning back.

I create tabs like

6条回答
  •  春和景丽
    2020-11-30 12:42

    Or more simply when navigating back to tabbedfragment (assuming you use an intent and the fragment is within an activity) use:

    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    

    This keeps the original activity and moves it to the top of the stack rather than recreating it, thus you never need to recreate the viewPager.

提交回复
热议问题