When is the best time to commit child fragments?
There is no information on the net on the nest Fragments
, so here is my question
Since child fragments can only be added dynamically, what is the best place to do this and why? I mean, the best answer for this operation: onCreate()
, onCreateView()
, onActivityCreated()
etc?
EDIT : I just tested it and it seems like there is no difference, it is possible to commit child fragments even in onAttach()
the callback of the parent fragment.
source to share
Ok, based on intuition and general idea of Fragment Life Cycle . I would say that you can safely do this in onCreateView()
. But I would experience it a little if I were you. The nested fragments still need to be action driven, so I'm pretty sure it can be done earlier, like in onCreate()
or onAttach()
.
source to share