I would like to have the listview in a ListActivity be displayed with the header and footer visible all the time even if the list data is empty.
An empty list causes the empty view to appear and the header and footer to disappear. However my header has filtering UI and should therefore always be visible.
The only way I can make it happen at the moment is if I take the header and footer out of the listview and implement them as static views outside in the activity layout. However then these are always visible and only the data scrolls.
I would prefer for both to just be on top and bottom of the scrolling list. Wrapping it all in a scroll view does not work since then there are two nested scroll views( the list view outside and the wrapping one).
Is there a way to do this nicely apart from a hack like adding a fake record?
Make your empty view include your header.
i.e.
<ListView />
<RelativeLayout
android:id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
// Add whatever you want here including your header
</RelativeLayout>
This answer is a bit late, but you can simply override BaseAdapter.isEmpty() to return false.
public boolean isEmpty() {
return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With