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

前端 未结 12 942
自闭症患者
自闭症患者 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 19:15

    For me, none of this answers worked for me. What I had to do was add the empty view manually (inflated) to the "parent" view of the Listview:

    ListView my_list = (ListView) findViewById(R.id.my_list);
    View emptyView = getLayoutInflater().inflate(R.layout.empty_view,null);
    ((ViewGroup)my_list.getParent()).addView(emptyView); 
    listView.setEmptyView(emptyView);
    

提交回复
热议问题