protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); expandableList = FindViewById(Resource.Id.expandList) as ExpandableListView; LoadData(); listAdapter = new ExpandableListAdapter(this, listHeaderData, listChildData); expandableList.SetAdapter(listAdapter); }
private void ViewModelPropertyChanged(object sender, PropertyChangedEventArgs args) { if (args.PropertyName == "PierResponse") { if (ViewModel.PierResponse != null) { GetPierLocations(); var mainActivity = Activity as MainMenuView; listAdapter = new ExpandableListAdapter(mainActivity, listDataHeader, listDataChild); expListView.SetAdapter(listAdapter); FnClickEvents(); } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.AppdrawerLayout); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.drawer_open, Resource.String.drawer_close); drawerLayout.AddDrawerListener(drawerToggle); drawerToggle.SyncState(); SupportActionBar.Title = "Hello Native App"; ExpandableListView expandableList = FindViewById <ExpandableListView>(Resource.Id.navigationmenu); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); expandableList.ChildClick += ExpandableList_ChildClick; navigationView.NavigationItemSelected += OnNavigationItemSelected; PrepareListData(); menuAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild, expandableList); // setting list adapter expandableList.SetAdapter(menuAdapter); }
private void SetData(out ExpandableListAdapter mAdapter) { client.SendString("SZ_GET_TIMETABLE=" + globals.compId); string res = client.ReceiveResponse(); var json = JsonObject.Parse(res); heats = (JsonArray)json["items"]; string[] groups = get_timetable_groups(); for (int i = 0; i < groups.Length; i++) { string[] groupA = get_group_children(groups[i]); group.Add(groups[i]); dicMyMap.Add(group[i], groupA.ToList()); } mAdapter = new ExpandableListAdapter(this, group, dicMyMap); }
/// <summary> /// This method is called when new instructions that have been polled were added, updated or deleted. /// It causes a modal pop up to appear showing the new instructions and what action was taken to them. /// </summary> /// <param name="alteredInstructions">The list of instructions to display</param> /// <param name="done">The action that is taken when the postive button is pressed</param> /// <param name="title">Title of the modal</param> /// <param name="okButton">The text of the positive button</param> public void PopUpInstructionNotification(List <ManifestInstructionViewModel> alteredInstructions, Action <List <ManifestInstructionViewModel> > done = null, string title = "", string okButton = "OK") { Application.SynchronizationContext.Post(ignored => { if (CurrentActivity == null) { return; } //This closes the pop if its showing so it can reopen another, else it will play sound and vibrate first time. if (InstructionNotificationDialog != null && InstructionNotificationDialog.IsShowing) { try { InstructionNotificationDialog.Dismiss(); InstructionNotificationDialog = null; } catch (Exception ex) { throw; } } else { Vibrate.VibrateDevice(); Sound.Play(); } var customView = CurrentActivity.LayoutInflater.Inflate(Resource.Layout.PopUp_InstructionNotification, null); InstructionGroupedListObject addInstructions = new InstructionGroupedListObject(); InstructionGroupedListObject updateInstructions = new InstructionGroupedListObject(); InstructionGroupedListObject deleteInstructions = new InstructionGroupedListObject(); InstructionGroupedListObject messages = new InstructionGroupedListObject(); InstructionGroupedListObject messagesWithPoints = new InstructionGroupedListObject(); CurrentPopInstructions.AddRange(alteredInstructions); //Filter the instructions into SyncStates (Added, Updated, Deleted) foreach (var instruction in CurrentPopInstructions) { if (instruction.InstructionType == InstructionType.OrderMessage) { if (instruction.MobileData.Order.Addresses == null) { messages.Instructions.Add(instruction); } else { messagesWithPoints.Instructions.Add(instruction); } } else { switch (instruction.MobileData.SyncState) { case SyncState.Add: addInstructions.Instructions.Add(instruction); break; case SyncState.Update: updateInstructions.Instructions.Add(instruction); break; case SyncState.Delete: deleteInstructions.Instructions.Add(instruction); break; } } } var inoList = new List <InstructionGroupedListObject>(); var headers = new List <string>(); if (addInstructions.Instructions.Count > 0) { inoList.Add(addInstructions); headers.Add("Instructions added (" + addInstructions.Instructions.Count + ")"); } if (updateInstructions.Instructions.Count > 0) { inoList.Add(updateInstructions); headers.Add(" Instructions updated (" + updateInstructions.Instructions.Count + ")"); } if (deleteInstructions.Instructions.Count > 0) { inoList.Add(deleteInstructions); headers.Add("Instructions deleted (" + deleteInstructions.Instructions.Count + ")"); } if (messages.Instructions.Count > 0) { inoList.Add(messages); headers.Add("Messages added (" + messages.Instructions.Count + ")"); } if (messagesWithPoints.Instructions.Count > 0) { inoList.Add(messagesWithPoints); headers.Add("Messages with points added (" + messagesWithPoints.Instructions.Count + ")"); } if (inoList.Count > 0) { //Create the expandableListView to be displayed var expandableListView = (ExpandableListView)customView.FindViewById(Resource.Id.instuctionList); expandableListView.ChildClick += expandableListView_ChildClick; var expandableListAdapter = new ExpandableListAdapter(CurrentActivity, headers, inoList); expandableListView.SetAdapter(expandableListAdapter); //Expand all the sections from the start. for (int i = 0; i < expandableListAdapter.GroupCount; i++) { expandableListView.ExpandGroup(i); } //Create the dialog popup var notificationDialog = new AlertDialog.Builder(CurrentActivity) .SetView(customView) .SetTitle(title) //Prevent the user from closing the pop up by clicking on the sides. .SetCancelable(false) .SetPositiveButton(okButton, (s, e) => { if (done != null) { done(CurrentPopInstructions); CurrentPopInstructions.Clear(); } }); InstructionNotificationDialog = notificationDialog.Create(); InstructionNotificationDialog.Show(); } }, null); }