Fragment/Activity Lifecycles and Orientation Change

后端 未结 1 1319
小蘑菇
小蘑菇 2021-02-04 11:39

Fragments are funny things but, so I thought, once you know their quirks they\'re an invaluable tool for writing good code across multiple devices.

However, while fixing

1条回答
  •  北荒
    北荒 (楼主)
    2021-02-04 12:17

    Argh,

    01-04 15:46:23.175: W/MainMenuFragment   0: onAttach() to SinglePaneActivity 0
    01-04 15:46:23.179: W/MainMenuFragment   0: onCreate()
    01-04 15:46:23.246: W/MainMenuFragment   0: onActivityCreated() with Activity SinglePaneActivity 0
    01-04 15:46:23.269: W/MainMenuFragment   0: onStart()
    01-04 15:46:23.269: W/SinglePaneActivity 0: onStart()
    

    Why the heck there is an onAttach() method I have no idea. Especially since "attach" happens before there is an Activity.

    The method I needed was of course, onActivityCreated() which happens as the final call in the "Creation" set of Fragment lifecycle events.

    0 讨论(0)
提交回复
热议问题