Getting reference to nested fragment from FragmentTabHost

后端 未结 4 511
走了就别回头了
走了就别回头了 2021-02-07 05:11

In my application, I use an Activity which holds one Fragment with FragmentTabHost and hence all its tabs are nested Fragments

4条回答
  •  醉话见心
    2021-02-07 05:49

    Well, exploring the source code of FragmentTabHost I've found that when it adds a fragment tab, it assignes a tag of TabSpec to nested Fragment.

    So to get the reference to this Fragment we should call

    getChildFragmentManager().findFragmentByTag(tabSpecTag)

提交回复
热议问题