ListFragment does not accept my layout

前端 未结 10 1386
情歌与酒
情歌与酒 2020-12-01 02:09

According to this link: ListFragment android developers

I want to set my custom layout for list, but it makes exceptions.

Here is the code:

p         


        
10条回答
  •  无人及你
    2020-12-01 02:54

    This code worked for me:

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View root = super.onCreateView(inflater, container, savedInstanceState);
    
        ((TextView)root.findViewById(0x00ff0001)).setText("some text");
    
        ListView list = (ListView) root.findViewById(android.R.id.list);
        list.setEmptyView(root.findViewById(0x00ff0001));
    
        return root;
    }
    

提交回复
热议问题