reusing fragments in a fragmentpageradapter

前端 未结 6 544
陌清茗
陌清茗 2020-11-28 02:19

I have a viewpager that pages through fragments. My FragmentPagerAdapter subclass creates a new fragment in the getItem method which seems wasteful

6条回答
  •  [愿得一人]
    2020-11-28 02:42

    For future readers!

    If you are thinking of reusing fragments with viewpager, best solution is to use ViewPager 2, since View Pager 2 make use of RecyclerView.

    • Medium article - Exploring the View Pager 2
    • Docs
    • Samples repo
    • Release notes

提交回复
热议问题