Answer the question
In order to leave comments, you need to log in
How not to call OnCreateView on popBackStack?
I'm using the BottomNavigation template. When you call findNavController().navigate(id)
, followed by a call findNavController().popBackStack()
or action "Back", the application jumps to the previous fragment, but creates it again. Also, OnCreateView is called if the navigation button is clicked many times, despite the fact that the current fragment is the same one that the button is bound to. I found a solution on SOF in order to save the view and then return it at the next OnCreateView, but I also read there that you can’t do this, because it can cause a memory leak. So how do I solve this problem and return to the previous fragment from the stack in the state from which I previously moved?
Answer the question
In order to leave comments, you need to log in
This is correct behavior, the view must be recreated. The state must be stored separately and be able to restore. Otherwise, no memory will be enough.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question