Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add&replace #25

Closed
tenSunFree opened this issue Sep 4, 2017 · 1 comment
Closed

add&replace #25

tenSunFree opened this issue Sep 4, 2017 · 1 comment

Comments

@tenSunFree
Copy link

tenSunFree commented Sep 4, 2017

具体问题描述

add
01

replace
02

我有個疑問, 如果將add 修改成replace, 會是比較好的選擇嗎? 為什麼?

@cgspine
Copy link
Collaborator

cgspine commented Sep 4, 2017

image

replace 的本质是 remove 已经 add 的 fragment,然后 add 新的 fragment。如果是第一个 fragment 的话,replace 和 add 最后的效果一样,但 replace 会走更多的逻辑判断。

第二个 fragment 以及之后加入的 fragment 应该用 replace,因为这样可以释放 View, 代码可见
BaseFragmentActivity.startFragment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants