Android getting fragment that is in FragmentPagerAdapter

后端 未结 5 1801
南方客
南方客 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:12

    A simpler approach to this is to get the Tags directly from the Fragment Manager; like this:

    fm.getFragments().get(0).getTag()
    

    You can replace the position, depending on the fragment you need the tag for. Hope this helps others!.

提交回复
热议问题