Android: set empty view to a list view

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

        
5条回答
  •  佛祖请我去吃肉
    2020-12-28 17:58

    You have to set the empty view before setting the adapter, if your MainActivity is not extending ListActivity.

    Try this

    list.setEmptyView(findViewById(android.R.id.empty));
    list.setAdapter(adapter);
    

    Sorry for the late answer!

    Alternate method: Make your activity extend from ListActivity. And add a textview to your list layout with id android.R.id.empty

提交回复
热议问题