protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; // ExpandableListModel.GenerateData(ref ListData, this); ListView = (ExpandableListView)this.FindViewById <Android.Widget.ExpandableListView>(Resource.Id.apps); ListAdapter = new ExpandableListAdapter(this, ListData, ListView); ListView.SetAdapter(ListAdapter); ListView.SetOnGroupClickListener(this); ListView.SetOnChildClickListener(this); // DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close); drawer.AddDrawerListener(toggle); toggle.SyncState(); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); navigationView.SetNavigationItemSelectedListener(this); }
/// <summary> /// ExpandableListAdapter constructor. Set up a long click listener and the group expander helper class /// </summary> /// <param name="context"></param> /// <param name="view"></param> /// <param name="provider"></param> public ExpandableListAdapter(Context context, ExpandableListView view, IGroupContentsProvider <T> provider, ExpandableListAdapterModel model, IAdapterEventHandler stateChange) { // Save the parameters adapterModel = model; contentsProvider = provider; parentView = view; stateChangeReporter = stateChange; // Save the inflator to use when creating the item views inflator = LayoutInflater.FromContext(context); // Set up listeners for group and child selection and item long click parentView.SetOnGroupClickListener(this); parentView.SetOnChildClickListener(this); parentView.OnItemLongClickListener = this; parentView.SetOnScrollListener(this); }
/// <summary> /// Setups the side menu. /// </summary> /// <returns>The side menu.</returns> private async void SetupSideMenu() { LoginResponse loginResponseObj = mSharedPreferencesManager.GetLoginResponse(); drawerList = FindViewById <RelativeLayout>(Resource.Id.left_drawer); TextView txt_user_name = FindViewById <TextView>(Resource.Id.txt_user_name); TextView txt_user_email = FindViewById <TextView>(Resource.Id.txt_user_email); txt_user_name.Text = loginResponseObj.Name; txt_user_email.Text = loginResponseObj.UserEmail; menuListView = FindViewById <ExpandableListView>(Resource.Id.listview); menuListView.SetOnChildClickListener(this); menuListView.SetOnGroupClickListener(this); menuListView.SetOnGroupExpandListener(this); menuList = GetExpandableMenuItem(); mAdapter = new SideMenuListExpandableAdapter(mActivity, menuList); // set up the drawer's list view with items and click listener menuListView.SetAdapter(mAdapter); drawerToggle = new MyActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.open_drawer, Resource.String.close_drawer); drawerLayout.AddDrawerListener(drawerToggle); SupportActionBar.SetDisplayShowHomeEnabled(true); drawerToggle.SyncState(); drawerToggle.DrawerIndicatorEnabled = true; // Call Email Count webservice await GetEmailCounts(); }