1 min readApr 17, 2019
These are more general questions about Fragments.
- Every time you add (or replace) a new Fragment to the
FragmentManager
in aFragmentTransaction
, you need to instantiate a new Fragment. If you use the Navigation architecture component in your project, it does it for you. - Fragment instances are reused as long as they are in the
FragmentManager
. Once created, they can be detached/attached multiple times, meaning that their view hierarchy may be created and destroyed multiple times. Once a fragment is destroyed (onDestroy()
is called) and removed from theFragmentManager
, it must not be reused.