ncapdevi / FragNav

An Android library for managing multiple stacks of fragments
1.5k stars 220 forks source link

call onResume when switch tab #215

Closed mahramane closed 5 years ago

mahramane commented 5 years ago

Hi can i call only the onResume() method when swith tab?

fragmentHideStrategy = FragNavController.DETACH call onCreateView() , onViewCreated(), onResume() and fragmentHideStrategy = FragNavController.HIDE call none from them.

ncapdevi commented 5 years ago

All of the lifecycle stuff is really outside of FragNav control (other than using the defined OS methods of hide, detach, or remove) https://stackoverflow.com/questions/9156406/whats-the-difference-between-detaching-a-fragment-and-removing-it . This stack overflow question should give you a bit more insight. However, because this isn't a FragNav specific problem, there are plenty of discussions and potential solutions https://stackoverflow.com/questions/12201695/oncreateview-called-multiple-times-working-with-actionbar-and-fragments .

Without knowing the specifics of what you are trying to do, it's likely that you're either not resetting the state in onDestroyView (which you should be doing) or that you are maybe doing something within oncreateview/onviewcreated that may belong in a different lifecycle callback. Either way, it's not something that FragNav has specific control over, so the Android Framework should have a solution for what you're looking for. Hope this helps!