Open HeQuanLi opened 4 years ago
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.
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?
@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.
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