I don't understand why adding a Header
or Footer
view to a ListView
is such a big deal.
Sure there are some quirks with adding them directly to MvxListView
, but you could do the work yourself with very little effort.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/header"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Header content here -->
</LinearLayout>
<LinearLayout
android:id="@+id/footer"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Footer content here -->
</LinearLayout>
<MvxListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/header"
android:layout_above="@+id/footer"
local:MvxBind="ItemsSource Items; ItemSelected SelectedItem"/>
</RelativeLayout>
Then you can add a EventHandler
to the Scroll
event if you want to show/hide the footer whether you have reached the bottom:
var footer = FindViewById<LinearLayout>(Resource.Id.footer);
var lv = FindViewById<MvxListView>(Resource.Id.listview);
lv.Scroll += (s, e) =>
{
var lastItem = e.FirstVisibleItem + e.VisibleItemCount;
if(lastItem == e.TotalItemCount)
{
// we are at the end of the list
// maybe do some animation before showing it
footer.Visibility = ViewStates.Visible;
}
else
{
footer.Visibility = ViewStates.Gone;
}
};