Retrieve a Fragment from a ViewPager

前端 未结 23 2537
逝去的感伤
逝去的感伤 2020-11-21 11:13

I\'m using a ViewPager together with a FragmentStatePagerAdapter to host three different fragments:

  • [Fragment1]
  • [Fragment2]<
23条回答
  •  遇见更好的自我
    2020-11-21 11:48

    In order to get current Visible fragment from ViewPager. I am using this simple statement and it's working fine.

          public Fragment getFragmentFromViewpager()  
          {
             return ((Fragment) (mAdapter.instantiateItem(mViewPager, mViewPager.getCurrentItem())));
          }
    

提交回复
热议问题