what is the different between onCreate() and onCreateView() lifecycle methods in Fragment?

后端 未结 3 1090
执笔经年
执笔经年 2020-12-30 19:48

I don\'t know when to use onCreate() or onCreateView().

I have used onCreate() and onCreateView() lifecycle metho

3条回答
  •  生来不讨喜
    2020-12-30 20:21

    onCreate is called on initial creation of the fragment. You do your non graphical initializations here. It finishes even before the layout is inflated and the fragment is visible.

    onCreateView is called to inflate the layout of the fragment i.e graphical initialization usually takes place here. It is always called sometimes after the onCreate method.

提交回复
热议问题