Binary XML file line #9: Error inflating class fragment

后端 未结 3 404
情书的邮戳
情书的邮戳 2021-01-11 12:11

Am getting Error inflating fragment error while running calling an Activity which having fragments.

CheckList is Activity which contains listview

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-11 12:57

    I just removed onCreateView code which contains inflating xml in listview fragmentand move into onActivityCreated method with that its working.

    The reason may be:
    

    ListFragment has a default layout that consists of a single list view. However, if you desire, you can customize the fragment layout by returning your own view hierarchy from onCreateView(LayoutInflater, ViewGroup, Bundle). To do this, your view hierarchy must contain a ListView object with the id "@android:id/list" (or list if it's in code)

    So my listview extends ListFragment and not conatining list in xml , and directly we can setListAdapter in onActivityCreated rather than in onCreateView.

提交回复
热议问题