//@@todo: remove //private void ShowAddressBook() //{ // var builder = new Android.Support.V7.App.AlertDialog.Builder(Context); // builder.SetTitle("Address book"); // LayoutInflater layoutInflater = Activity.LayoutInflater; // View view = layoutInflater.Inflate(Resource.Layout.addressbooklayoutex, null, false); // ExpandableListView expandableListView = view.FindViewById<ExpandableListView>(Resource.Id.exapndableListView); // PrepareAddressBook(); // ExpandableListAdapter expandableListAdapter = new ExpandableListAdapter(builder.Context, listDataHeader, listDataChild, // expandableListView); // expandableListView.SetAdapter(expandableListAdapter); // expandableListView.ChildClick += delegate (object sender, ExpandableListView.ChildClickEventArgs e) // { // List<KeyValuePair<string,int>> ls = listDataChild[listDataHeader[e.GroupPosition]]; // if (ls[(int)e.Id].Key == "Portfolio") // { // } // //Toast.MakeText(this, "child clicked : " + ls[(int)e.Id], ToastLength.Short).Show(); // }; // builder.SetView(view); // builder.SetPositiveButton("Ok", (senderAlert, args) => // { // }); // builder.SetNegativeButton(Resource.String.cancel, (senderAlert, args) => { }); // builder.Show(); //} private void AddToAddressBook(string name, string phoneNumber, string address, string emailAddress) { ExpandedMenuModel item1 = new ExpandedMenuModel(); item1.Name = name; item1.Image = Resource.Drawable.ic_account_circle_black_18dp; // Adding data header listDataHeader.Add(item1); // Adding child data List <KeyValuePair <String, int> > heading1 = new List <KeyValuePair <String, int> >(); heading1.Add(new KeyValuePair <string, int>(phoneNumber, Resource.Drawable.ic_phone_blue_light_18dp)); heading1.Add(new KeyValuePair <string, int>(address, Resource.Drawable.ic_qr_code_scan_blue)); heading1.Add(new KeyValuePair <string, int>(emailAddress, Resource.Drawable.ic_email_blue_light_18dp)); listDataChild.Add(listDataHeader[index], heading1);// Header, Child data index++; }
private void PrepareListData() { listDataHeader = new List <ExpandedMenuModel>(); listDataChild = new Dictionary <ExpandedMenuModel, List <String> >(); ExpandedMenuModel item1 = new ExpandedMenuModel(); item1.Name = "heading1"; item1.Image = Resource.Drawable.abc_ic_menu_copy_mtrl_am_alpha; listDataHeader.Add(item1); ExpandedMenuModel item2 = new ExpandedMenuModel(); item2.Name = "heading2"; item2.Image = Resource.Drawable.abc_ic_voice_search_api_material; listDataHeader.Add(item2); ExpandedMenuModel item3 = new ExpandedMenuModel(); item3.Name = "heading3"; item3.Image = Resource.Drawable.abc_ic_menu_share_mtrl_alpha; listDataHeader.Add(item3); ExpandedMenuModel item4 = new ExpandedMenuModel(); item4.Name = "heading4"; item4.Image = Resource.Drawable.abc_ic_menu_paste_mtrl_am_alpha; listDataHeader.Add(item4); ExpandedMenuModel custom = new ExpandedMenuModel(); custom.Name = "custom"; custom.Image = Resource.Drawable.abc_btn_switch_to_on_mtrl_00001; listDataHeader.Add(custom); // Adding child data List <String> heading1 = new List <String>(); heading1.Add("Submenu of item 1"); heading1.Add("Submenu of item 1"); heading1.Add("Submenu of item 1"); List <String> heading2 = new List <String>(); heading2.Add("Submenu of item 2"); heading2.Add("Submenu of item 2"); heading2.Add("Submenu of item 2"); List <String> heading3 = new List <String>(); heading3.Add("Submenu of item 3"); heading3.Add("Submenu of item 3"); List <String> heading4 = new List <String>(); heading4.Add("Submenu of item 4"); heading4.Add("Submenu of item 4"); List <string> customHeading = Enumerable.Range(0, 4).Select(x => "Custom child " + (x + 1)).ToList(); listDataChild.Add(listDataHeader[0], heading1); listDataChild.Add(listDataHeader[1], heading2); listDataChild.Add(listDataHeader[2], heading3); listDataChild.Add(listDataHeader[3], heading4); listDataChild.Add(listDataHeader[4], customHeading); }