Ken*_*Son -2 android android-fragments
我正在寻找答案,但找不到以下内容。
getFragmentManager().beginTransaction().add()并且片段B可见所以我的问题是,当片段B被分离时,片段A中的哪个方法将被调用,我正在调试片段A中的所有onResume,onAttach,但看起来好像没有被调用。
有一点是,如果我们使用替换片段而不是添加片段,它将在片段生命周期中运行提取,但是使用“添加”方法,看起来片段A在屏幕上仍然可见,因此无论如何要检测片段A是否未被片段覆盖B了吗?
有任何想法吗?
当用户浏览一项活动以细分时,其生命周期低于
FirstFragment:onAttach
FirstFragment:onCreate
FirstFragment:onCreateView
FirstFragment:onViewCreated
FirstFragment:onActivityCreated
FirstFragment:onStart
FirstFragment:onResume
如果在addtobackstack和add()的情况下,用户将第一片段导航到第二片段,则在生命周期以下称为SecondFragment:onAttach
SecondFragment:onCreate
SecondFragment:onCreateView
SecondFragment:onViewCreated
SecondFragment:onActivityCreated
SecondFragment:onStart
SecondFragment:onResume
当用户在addtobackstack()和add()情况下按下时,则在生命周期以下称为SecondFragment:onPause
SecondFragment:onStop
SecondFragment:onDestroyView
SecondFragment:onDestroy
SecondFragment:onDetach
如果在addtobackstack和replace()的情况下,用户将第一片段导航到第二片段,则在生命周期以下,称为SecondFragment:onAttach
SecondFragment:onAttachonAttach
SecondFragment:onCreate
FirstFragment:onPause
FirstFragment:onStop
FirstFragment:onDestroyView
SecondFragment:onCreateView
SecondFragment:onViewCreated
SecondFragment:onActivityCreated
SecondFragment:onStart
SecondFragment:onResume
当用户在addtobackstack()的情况下按下并替换,然后在生命周期以下调用SecondFragment时:onPause
SecondFragment:onStop
SecondFragment:onDestroyView
SecondFragment:onDestroy
SecondFragment:onDetach
FirstFragment:onCreateView
FirstFragment:onViewCreated
FirstFragment:onActivityCreated
FirstFragment:onStart
FirstFragment:onResume
| 归档时间: |
|
| 查看次数: |
1045 次 |
| 最近记录: |