Drimmka
Drimmka

Reputation: 546

What is the difference between fragmentTransaction.remove and setVisibility(GONE);

What is the better practice for removing fragments (when the animation is not required) using fragmentTransaction.remove or changing the fragment container view visibility to GONE - setVisibility(GONE);

Upvotes: 0

Views: 553

Answers (1)

Justin Breitfeller
Justin Breitfeller

Reputation: 13801

Removing the fragment will cause the entire fragment to be destroyed (onStop and onDestroy will be called).

Setting the visiblity to GONE will only hide the view from the user. The fragment instance will still exist and run through life cycle events.

Upvotes: 1

Related Questions