In my application, I use an Activity
which holds one Fragment
with FragmentTabHost
and hence all its tabs are nested Fragments
Above solutions are also working but I have one more easy solution,
@Override
public void onTabChanged(final String tabId) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mFragment = getChildFragmentManager().findFragmentByTag("Tagname");
}
},1000);
}
Here you have to implement FragmentTabHost.onTabChangeListener We have kept a second delay in fetching fragment from the childFragmentManager.
Note : You need to cast mFragment which fragment you have used.