private void SetNavigationViewListener() { NavigationView navigationView = drawerLayout.FindViewById <NavigationView>(Resource.Id.nav_view); navigationView.SetNavigationItemSelectedListener(this); var navHeader = navigationView.GetHeaderView(0); navHeader.SetOnClickListener(this); }
private void SetMenu() { var home = drawerLayout.FindViewById <LinearLayout>(Resource.Id.lytHome); home.Click += (sender, e) => { ViewModel.MainScreenCommand.Execute(null); drawerLayout.CloseDrawer(drawerMenu); }; var second = drawerLayout.FindViewById <LinearLayout>(Resource.Id.lytSecondView); second.Click += (sender, e) => { ViewModel.SecondScreenCommand.Execute(null); drawerLayout.CloseDrawer(drawerMenu); }; }
public override void SetContentView(int layoutResID) { fullView = (DrawerLayout)LayoutInflater.Inflate(Resource.Layout.AcBase, null); FrameLayout activityContainer = fullView.FindViewById <FrameLayout>(Resource.Id.activity_content); LayoutInflater.Inflate(layoutResID, activityContainer, true); base.SetContentView(fullView); Android.Support.V7.Widget.Toolbar toolbar = fullView.FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SetTitle(Resource.String.app_name); SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.edit); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.navigationView); navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected; }
public override void SetContentView(int layoutResID) { _view = (DrawerLayout)LayoutInflater.Inflate(Resource.Layout.BaseActivity, null); var activityContainer = _view.FindViewById <FrameLayout>(Resource.Id.activity_content); LayoutInflater.Inflate(layoutResID, activityContainer, true); base.SetContentView(_view); _toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(_toolbar); SupportActionBar.SetTitle(_titleName); var drawerToggle = new ActionBarDrawerToggle (this, _view, _toolbar, Resource.String.nav_open, Resource.String.nav_close); _view.AddDrawerListener(drawerToggle); drawerToggle.SyncState(); _navigationView = FindViewById <NavigationView>(Resource.Id.navigation_view); _navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); //ActionBar.NavigationMode = ActionBarNavigationMode.Tabs; // Set our view from the "main" layout resource SetContentView(Resource.Layout.MainView); pref = PreferenceManager.GetDefaultSharedPreferences(this); _mToolbar = FindViewById <SupportToolbar>(Resource.Id.toolbar); // Inflate the "decor.xml" //LayoutInflater inflater = (LayoutInflater) GetSystemService(Context.LayoutInflaterService); //_mDrawerLayout = (DrawerLayout) inflater.Inflate(Resource.Layout.DrawerView, null); // "null" is important. var view1 = LayoutInflater.From(this).Inflate(Resource.Layout.DrawerView, null, false); // HACK: "steal" the first child of decor view _mDrawerLayout = view1.FindViewById <DrawerLayout>(Resource.Id.drawer_layout); ViewGroup decor = (ViewGroup)Window.DecorView; View child = decor.GetChildAt(0); decor.RemoveView(child); _container = _mDrawerLayout.FindViewById <LinearLayout>(Resource.Id.fragmentContainer); var container = (FrameLayout)_mDrawerLayout.FindViewById(Resource.Id.container); // This is the container we defined just now. container.AddView(child); // Make the drawer replace the first child decor.AddView(_mDrawerLayout); //_mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); _mLeftDrawer = _mDrawerLayout.FindViewById <ListView>(Resource.Id.left_drawer); DisplayMetrics displayMetrics = Resources.DisplayMetrics; Android.Views.ViewGroup.LayoutParams lp = (Android.Views.ViewGroup.LayoutParams)_mLeftDrawer.LayoutParameters; lp.Height = displayMetrics.HeightPixels; _mLeftDrawer.LayoutParameters = lp; //_mLeftDrawer.SetMinimumHeight (displayMetrics.HeightPixels+GetStatusBarHeight()+(int)(48*displayMetrics.Density)); //mToolbar.SystemUiVisibility = // (StatusBarVisibility)Android.Views.SystemUiFlags.LowProfile; _mToolbar.SetPadding(0, GetStatusBarHeight(), 0, 0); _mToolbar.LayoutParameters.Height = (int)(52 * displayMetrics.Density) + GetStatusBarHeight(); SetSupportActionBar(_mToolbar); _mDrawerToggle = new MyDrawerToggle( this, //Host Activity _mDrawerLayout, //DrawerLayout Resource.String.profile, //Opened Message Resource.String.hot_title, //Closed Message pref ); _mDrawerLayout.SetDrawerListener(_mDrawerToggle); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayShowTitleEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); //SupportActionBar.NavigationMode = (int)ActionBarNavigationMode.Standard; _mDrawerToggle.SyncState(); //_container = FindViewById<LinearLayout>(Resource.Id.fragmentContainer); _posts = new List <Post>(); var root2 = LayoutInflater.Inflate(Resource.Layout.PostFragmentRecycleView, _container, false); var recyclerView = root2.FindViewById <RecyclerView>(Resource.Id.postRecycleView); _container.AddView(root2); _recyclerView = recyclerView; //recyclerView.HasFixedSize = true; //recyclerView.SetItemAnimator(new DefaultItemAnimator()); _recyclerView.SetLayoutManager(new LinearLayoutManager(this)); //recyclerView.AddItemDecoration(new DividerItemDecoration(Activity, DividerItemDecoration.HorizontalList)); _recyclerView.NestedScrollingEnabled = false; //mEmails.Add(new Email() { Name = "tom", Subject = "Wanna hang out?", Message = "I'll be around tomorrow!!" }); var adapter = new PostViewAdapter(_posts, _recyclerView, this); _adapter = adapter; _adapter.HasStableIds = true; _recyclerView.SetAdapter(_adapter); _recyclerView.AddOnScrollListener(new MyScrollListener()); Task.Factory.StartNew(async() => { try{ var newPostList = new List <Post>(); var editor = pref.Edit(); editor.PutString("CurrentPage", "0"); editor.PutString("CurrentChanel", Resource.Id.hotRowLayout.ToString()); editor.Apply(); await WebClient.LoadPosts(newPostList, 1); _posts.AddRange(newPostList); //(_RecyclerView.GetAdapter()as PostViewAdapter)._Posts.AddRange(newPostList); //_RecyclerView.GetAdapter().NotifyItemRangeInserted(_RecyclerView.GetAdapter().ItemCount,newPostList.Count); //recyclerView.GetAdapter().HasStableIds = true; //recyclerView.GetAdapter().NotifyDataSetChanged(); //_RecyclerView.GetAdapter().NotifyDataSetChanged(); RunOnUiThread(() => { _adapter.NotifyDataSetChanged(); }); } catch (Exception ex) { // ignored Insights.Report(ex, new Dictionary <string, string> { { "Message", ex.Message } }, Insights.Severity.Error); Toast.MakeText(this, ex.Message, ToastLength.Short).Show(); } }); _mLeftDrawer.Tag = 0; //mRightDrawer.Tag = 1; EventHandler headerClick = (object sender, EventArgs e) => { var layout = (RelativeLayout)sender; var currentChanel = String.Empty; switch (layout.Id) { case Resource.Id.hotRowLayout: currentChanel = Resource.Id.hotRowLayout.ToString(); break; case Resource.Id.bestRowLayout: currentChanel = Resource.Id.bestRowLayout.ToString(); break; case Resource.Id.newRowLayout: currentChanel = Resource.Id.newRowLayout.ToString(); break; default: currentChanel = Resource.Id.hotRowLayout.ToString(); break; } var editor = pref.Edit(); editor.PutString("CurrentChanel", currentChanel); editor.Apply(); _mDrawerLayout.CloseDrawers(); Reload(); }; int [] prgmImages = { Resource.Drawable.ic_camera_64, Resource.Drawable.ic_star_64, Resource.Drawable.ic_comments_64, Resource.Drawable.ic_menu_64 }; String [] prgmNameList = { "Сообщения", "Избранное", "Моя лента", "Мои коммнтарии" }; var drawerAdapter = new DrawerListAdapter(this, Resource.Array.drawerListItems, Resource.Array.drawerListIcons, new DrawerListBadges { Feed = 0, Messages = 1 }); _mLeftDrawer.Adapter = drawerAdapter; _mLeftDrawer.DividerHeight = 0; var drawerListHeader = LayoutInflater.Inflate(Resource.Layout.DrawerListHeader, null); var hotRowLayout = drawerListHeader.FindViewById <RelativeLayout> (Resource.Id.hotRowLayout); var bestRowLayout = drawerListHeader.FindViewById <RelativeLayout> (Resource.Id.bestRowLayout); var newRowLayout = drawerListHeader.FindViewById <RelativeLayout> (Resource.Id.newRowLayout); hotRowLayout.Click += headerClick; bestRowLayout.Click += headerClick; newRowLayout.Click += headerClick; _mLeftDrawer.AddHeaderView(drawerListHeader, null, false); }