在onAttach()和onCreateView()之前调用的onResume()

时间:2020-02-28 08:35:32

标签: android-studio android-fragments android-activity android-lifecycle

我的问题是,当调用onResume()时,片段尚未创建,而我需要它们执行一些操作(在onResume中)

启动我的应用程序时,会发生以下情况:

OnCreate()-> OnStart()-> OnResume()-> getItem()-> OnAttach()-> OnCreateView()

虽然我正在查看片段和活动的生命周期架构,但在onResume()之前调用onAttach()和onCreateView(),在onCreate()之后调用juste

有什么主意吗?谢谢

编辑

我成功地将指令放入片段的onResume()中,但我仍然不明白为什么在片段的onAttach()之前调用活动的onResume()

编辑2

当我使用其他设备(在这种情况下为模拟器)启动应用程序时,活动的onResume()称为AFTER onAttach(),这一次... 我真的不明白。如果有人可以解释我,我将非常高兴:)

0 个答案:

没有答案
相关问题