Fragment

Activity Fragment生命周期执行顺序

Activity-onCreate

Fragment-onAttach

Activity-onAttachFragment

Fragment-onCreate

Fragment-onCreateView

Fragment-onActivityCreated

Activity-onStart

Fragment-onStart

(但是测试发现是Fragment-onStart在Activity-onStart前面)

Activity-onResume

Fragment-onResume

 

Fragment-onPause

Activity-onPause

Fragment-onSaveInstanceState

Activity-onSaveInstanceState

(测试发现这两个保存状态是在下面的两个stop之后)

Fragment-onStop

Activity-onStop

(测试发现Activity-onStop在Fragment-onStop之前)

Fragment-onDestroyView

Fragment-onDestroy

Fragment-onDetach

Acitivity-onDestroy

(测试发现Acitivity-onDestroy在Fragment-onDestroyView之前,很懵逼)

 

posted @ 2022-06-10 11:26  kerwinkeep  阅读(56)  评论(0)    收藏  举报