Replace the original fragment with the Replace method;
Use the Hide and show methods to show the fragment that have been added again.
You can use replace (r.id.layout,b). However, this leads to a problem where a will be destroyed after being replaced, and will call its life cycle function (Ondestoryview (), OnPause (), Ondestory ()).
If you frequently replace fragment will constantly create new instances, destroying the old ones and not reusing them.
Switching multiple times causes the view on the fragment to fail to load (the Oncreateview method is no longer called because the fragment instance is not created again after replace).
Summary: If the old fragment does not need to be reused, it can be destroyed using the Replace method.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. (reproduced please specify from Allencoder)
Fragment Loading Replace Add,show,hide,replace method