Android getting fragment that is in FragmentPagerAdapter

后端 未结 5 1802
南方客
南方客 2020-12-07 15:53

I have following problem: I have one activity in which I have two tabs which are made both as fragments using FragmentPagerAdapter In some moment I would l

5条回答
  •  爱一瞬间的悲伤
    2020-12-07 16:23

    The Fragments supplied by the FragmentPagerAdapter are auto-tagged when they're instantiated. You can retrieve the tag with this method:

    private static String makeFragmentName(int viewPagerId, int index) {
         return "android:switcher:" + viewPagerId + ":" + index;
    }
    

    Reference: reusing fragments in a fragmentpageradapter

提交回复
热议问题