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; } }
protected async override void OnCreate (Bundle bundle) { try { base.OnCreate (bundle); SetContentView (Resource.Layout.MakeBookingSesh); ActionBar.SetHomeButtonEnabled(true); ActionBar.SetDisplayHomeAsUpEnabled(true); if (ProgressDialogLogin == null) { ProgressDialogLogin = ProgressDialog.Show(this, "", "Loading..."); } string WorkshopSetId = Intent.GetStringExtra("WorkshopSetId"); _WorkshopSessions = await RESTClass.GetWorkshopSessions("?workshopSetId=" + WorkshopSetId); CreateExpandableListData(); elvExListBox = FindViewById<ExpandableListView> (Resource.Id.elvExListBox); elvExListBox.SetAdapter (new ExpandListSessionAdapter (this, dictGroup)); if (ProgressDialogLogin != null) { ProgressDialogLogin.Dismiss(); ProgressDialogLogin = null; } elvExListBox.ChildClick += delegate(object sender, ExpandableListView.ChildClickEventArgs e) { string itmGroup = lstKeys [e.GroupPosition]; WorkshopSessions itmChild = dictGroup [itmGroup]; }; elvExListBox.GroupExpand += delegate(object sender, ExpandableListView.GroupExpandEventArgs e) { if (lastExpandedPosition != -1 && e.GroupPosition != lastExpandedPosition) { elvExListBox.CollapseGroup(lastExpandedPosition); } lastExpandedPosition = e.GroupPosition; }; // Button btnViewDetails = FindViewById<Button>(Resource.Id.btnViewDetails); // btnViewDetails.Click += delegate { // StartActivity(new Intent(this, typeof(MakeBookingListActivity))); // }; } catch (Exception e) { ErrorHandling.LogError (e, this); } finally { if (ProgressDialogLogin != null) { ProgressDialogLogin.Dismiss(); ProgressDialogLogin = null; } } }