Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

HomeViewPagerFragment will re-execute onCreateView #569

Open
HeQuanLi opened this issue Jan 3, 2020 · 3 comments
Open

HomeViewPagerFragment will re-execute onCreateView #569

HeQuanLi opened this issue Jan 3, 2020 · 3 comments

Comments

@HeQuanLi
Copy link

HeQuanLi commented Jan 3, 2020

When I hit the back button on the PlantDetailFragment page to return to HomeViewPagerFragment, the HomeViewPagerFragment will re-execute onCreateView.What should I do if I don't want to.thank you

@Zhuinden
Copy link

Zhuinden commented Jan 20, 2020

Well replace.addToBackStack kills the previous view, and the only variant that doesn't (FragmentTransaction.show/hide) will eventually be deprecated because the Navigation team doesn't like it.

It is also impossible via setMaxLifecycle to make a Fragment stopped, but still keep its views alive.

@OCNYang
Copy link

OCNYang commented Dec 15, 2020

When I hit the back button on the PlantDetailFragment page to return to HomeViewPagerFragment, the HomeViewPagerFragment will re-execute onCreateView. Why can the state of viewPager be recorded in the demo?
It's exactly the same as it was when you entered the PlantDetailFragment.
the HomeViewPagerFragment will re-execute onCreateView.Shouldn't it be the initial display state?

I was confused and trying to find the answer. Can you give me some help?

@Zhuinden
Copy link

@OCNYang as you navigate forward, replace().addToBackStack() will kill the Fragment view, but it won't kill the Fragment. The child fragments within a ViewPager have their views destroyed along with the parent view, but the child fragments themselves are kept alive via the child fragment manager.

Not entirely sure what behavior you were looking for.

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

No branches or pull requests

4 participants
@HeQuanLi @Zhuinden @OCNYang and others