public override Java.Lang.Object InstantiateItem(ViewGroup container, int position) { try { View view; Int32 lastExpandedPosition = -1; CreateExpandableListData(); if (position == 0) //Current Booking tab { view = LayoutInflater.From(container.Context).Inflate(Resource.Layout.CurrentBookingLayout, container, false); container.AddView(view); flCurrentBookings = container.FindViewById <FrameLayout> (Resource.Id.flCurrentBookings); flNoCurrentBookings = container.FindViewById <FrameLayout> (Resource.Id.flNoCurrentBookings); elvCurrentBookings = container.FindViewById <ExpandableListView> (Resource.Id.elvCurrentBookings); if (dictGroupCurr.Count > 0) { flNoCurrentBookings.Visibility = ViewStates.Gone; flCurrentBookings.Visibility = ViewStates.Visible; elvCurrentBookings.SetAdapter(new ExpandViewBookingAdapter(parent, dictGroupCurr)); elvCurrentBookings.ChildClick += delegate(object sender, ExpandableListView.ChildClickEventArgs e) { string itmGroup = lstKeysCurr [e.GroupPosition]; WorkshopBooking itmChild = dictGroupCurr [itmGroup]; }; elvCurrentBookings.GroupExpand += delegate(object sender, ExpandableListView.GroupExpandEventArgs e) { if (lastExpandedPosition != -1 && e.GroupPosition != lastExpandedPosition) { elvCurrentBookings.CollapseGroup(lastExpandedPosition); } lastExpandedPosition = e.GroupPosition; }; } else { flNoCurrentBookings.Visibility = ViewStates.Visible; flCurrentBookings.Visibility = ViewStates.Gone; } } else //Past Bookings { view = LayoutInflater.From(container.Context).Inflate(Resource.Layout.PastBookings, container, false); container.AddView(view); flPastBookings = container.FindViewById <FrameLayout> (Resource.Id.flPastBookings); flNoPastBookings = container.FindViewById <FrameLayout> (Resource.Id.flNoPastBookings); elvPastBookings = container.FindViewById <ExpandableListView> (Resource.Id.elvPastBookings); if (dictGroupPast.Count > 0) { flNoPastBookings.Visibility = ViewStates.Gone; flPastBookings.Visibility = ViewStates.Visible; elvPastBookings.SetAdapter(new ExpandViewBookingAdapter(parent, dictGroupPast)); elvPastBookings.ChildClick += delegate(object sender, ExpandableListView.ChildClickEventArgs e) { string itmGroup = lstKeysPast [e.GroupPosition]; WorkshopBooking itmChild = dictGroupPast [itmGroup]; }; elvPastBookings.GroupExpand += delegate(object sender, ExpandableListView.GroupExpandEventArgs e) { if (lastExpandedPosition != -1 && e.GroupPosition != lastExpandedPosition) { elvPastBookings.CollapseGroup(lastExpandedPosition); } lastExpandedPosition = e.GroupPosition; }; } else { flNoPastBookings.Visibility = ViewStates.Visible; flPastBookings.Visibility = ViewStates.Gone; } } return(view); } catch (Exception e) { ErrorHandling.LogError(e, container.Context); return(-1); } }