Correct use of setEmtpyView in AdapterView

后端 未结 5 1087
情话喂你
情话喂你 2020-12-05 00:17

I\'m really having trouble using the setEmptyView method. I tried it to implement it in GridView and ListView, but both of them didnt work. Here a sample codeblock:

5条回答
  •  旧时难觅i
    2020-12-05 00:45

    You can define external XML layout files, inflate and set it as an empty view. Only thing to remember is to set the parent of the inflated view.

    View emptyView = inflater.inflate(R.layout.id_of_your_layoout_file, parent, false);
    gridView.setEmptyView(emptyView);
    

    or

    listView.setEmptyView(emptyView);
    

提交回复
热议问题