getChildFragmentManager

getChildFragmentManager() on programmatically (dynamically) added Fragments?

accepted

In conclusion, I want to reference OuterFrag in MainActivity always. And I want OuterFrag act as a placeholder to load different InnerFrags. In short, I want to call getChildFragmentManager() in OuterFrag, when it is added programmatically (dynamically).

If you want this then make your OuterFrag have a container layout as its content and add whatever InnerFrag to that container. The layout file for the OuterFrag will be:

 

Of course you could have other views in the layout for the OuterFrag if you want that. Then your addInnerFrag method will be:

 

The code for adding the OuterFrag to the main activity remains valid.

warningComments are closed.