Android: set empty view to a list view

前端 未结 5 524
情深已故
情深已故 2020-12-28 17:36
 

        
5条回答
  •  萌比男神i
    2020-12-28 17:54

    There are some correct answers, however, I think this is the best approach I've found:

    View emptyView = getLayoutInflater().inflate(R.layout.empty_list_cart, null);
    addContentView(emptyView, listView.getLayoutParams()); // You're using the same params as listView
    listView.setEmptyView(emptyView);
    listView.setAdapter(adapter);
    

提交回复
热议问题