Fragment.onCreateView has null container

后端 未结 1 924
礼貌的吻别
礼貌的吻别 2021-01-17 15:42

The following is running on an Android 1.6 so I\'m using the compatibility package for fragments. In the following TestFragment is a static nested class:

<
相关标签:
1条回答
  • 2021-01-17 16:03

    The documentation mentions that it can be null:

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

    [...]

    container: If non-null, this is the parent view that the fragment's UI should be attached to. The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view.

    To be clear: you shouldn't do anything like container.addView(...).

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