Android studio 在onAttach()和onCreateView()之前调用onResume()

Android studio 在onAttach()和onCreateView()之前调用onResume(),android-studio,android-fragments,android-activity,android-lifecycle,Android Studio,Android Fragments,Android Activity,Android Lifecycle,我的问题是,在调用onResume()时,我的片段尚未创建,而我需要它们执行一些操作(在onResume中) 当我启动应用程序时,会发生以下情况: OnCreate()->OnStart()->OnResume()->getItem()->OnAttach()-> OnCreateView() 当我查看片段和活动的生命周期模式时,在onResume()之前调用onAttach()和onCreateView(),在onCreate()之后调用just 有什么想法吗?谢谢 编辑 我成功地将指令放在片

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

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

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

当我查看片段和活动的生命周期模式时,在onResume()之前调用onAttach()和onCreateView(),在onCreate()之后调用just

有什么想法吗?谢谢

编辑

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

编辑2

当我用另一个设备启动我的应用程序时(在本例中是模拟器),活动的onResume()在onAttach()之后调用,这次。。。 我真的不明白。如果有人能给我解释一下,我会很高兴:)