ViewPager update fragment on swipe

前端 未结 4 732
孤城傲影
孤城傲影 2020-12-01 00:14

i have a problem that i have been struggling with for the past 2 days.

I am building an app that uses ActionBar, ViewPager & FragmentPagerAdapter. The code for

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 00:48

    Add this code when you define the Viewpager

    mViewPager.setOffscreenPageLimit(0);
    

    It will not save any view of the fragments when you switch to other fragment .. so switching from fragment to another will create the fragment from the start and update everything.

提交回复
热议问题