0
0 answers 2,301 views 6 years ago

Difference between adding/replacing fragment in backstack?

replace removes the existing fragment and adds a new fragment. This means when you press back button the fragment that got replaced will be created with its onCreateView being invoked.



add retains the existing fragments and adds a new fragment that means existing fragment will be active and they wont be in ‘paused’ state hence when a back button is pressed onCreateView is not called for the existing fragment(the fragment which was there before new fragment was added).



In terms of fragment’s life cycle events onPause, onResume, onCreateView and other life cycle events will be invoked in case of replace but they wont be invoked in case of add.

Share:
S
Student User
Asked 6 years ago

0 Answer(s)

No answers yet

Be the first to help by answering this question!

Login to Answer

Login Required

Please login to submit an answer.

Community pulse
  • Total questions216
  • Answers posted19
  • Accepted answers0
  • Active learners11

Need personalised help?

Start a new discussion and get answers from verified teachers & toppers.

Ask now