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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With