ListView setEmptyView In Android
Posted by admin on
July 12, 2011
If you wanted to use the setEmptyView() method of a ListView widget and it does not work, there is a big chance that you placed the layout in a separate file and called it from there. That will not work. What you need to do is place that same code within the layout file that will be used in your Activity file and set its visibility to GONE.
You do not need to manually set its visibility in case the ListView has no data. The widget itself will automatically handle the empty view’s visibility status.
If you placed the layout view for an empty ListView, you can use thetag and place it within the layout file that will be used in your Activity class.
If you want the setEmptyView() to be reset, just set null as its value.
Donations appreciated. Every little $ helps. Or click Google +1. Or play the short video on the upper right of this page.









