Reputation: 2509
Suppose, using Navigation Architecture Components, I'm within a fragment, Fragment_A
, and want to do a small task using a Headless fragment. My questions are:
How to properly/correct way to add a headless fragment from within Fragment_A
?
How to detect that I'm navigating out from Fragment_A
, that started the headless fragment so that I can remove the headless fragment?
Upvotes: 4
Views: 414
Reputation: 199795
You can add a headless fragment by using getChildFragmentManager()
and doing a normal FragmentTransaction
. The benefit of using the child FragmentManager
is that all of the child fragments are removed when the parent is removed.
Upvotes: 4