difference between fragmentTransaction.add and fragmentTransaction.replace

Viewed 26705

What I already known is:

after fragmentTransaction.replace(), current fragment's onStop() function will be called while fragmentTransaction.add() won't.

and after calling fragMgr.popBackStack();, we will return to previous fragment no matter fragmentTransaction.replace or fragmentTransaction.add() is used

So what does fragmentTransaction.replace do?

I can understand we can "add" a fragment opon a previous fragment and later return to previous fragment by popBackStack(), BUT:

if previous fragment is "replaced" by current fragment, I guess previous fragment is removed and current fragment is added in, how can it return to previous fragment when popBackStack() called?

2 Answers
Related