“Content has view with id attribute 'android.r.id.list' that is not a ListView Class.” when create a list view in a fragment

后端 未结 3 1686
南笙
南笙 2020-12-19 03:32

Here is the problem. I have a list view, and it looks fine in the building, but it broke the error. Content has view with id attribute \'android.r.id.list\' that is not a Li

3条回答
  •  盖世英雄少女心
    2020-12-19 04:08

    You can inflate your View on onCreateView() method in which layout your ListView and id of that ListView must be

    @android:id/list
    

    and after that on onCreateView() method

    ListView lv = (ListView)contactLayout.findViewById(android.R.id.list);
    

提交回复
热议问题