setEmptyView on ListView not showing its view in a android app?

前端 未结 12 947
自闭症患者
自闭症患者 2020-12-02 18:37

I have a problem with the setEmptyView method from a ListView.

Here is my Java code:

ListView view = (ListView)findViewById(R.id.listView1);
view.se         


        
12条回答
  •  甜味超标
    2020-12-02 18:56

    There are some correct solutions, but I think this is the best approach!

    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);
    

提交回复
热议问题