In my application, I use an Activity
which holds one Fragment
with FragmentTabHost
and hence all its tabs are nested Fragments
.
Inside an Activity
which holds a Fragment
with its nested Fragment
, we may get a reference to attached one using onAttachedFragment()
.
But how to get a reference to nested Fragment
from FragmentTabHost
?
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)