本文整理汇总了C#中DrawerLayout.SetDrawerListener方法的典型用法代码示例。如果您正苦于以下问题:C# DrawerLayout.SetDrawerListener方法的具体用法?C# DrawerLayout.SetDrawerListener怎么用?C# DrawerLayout.SetDrawerListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawerLayout
的用法示例。
在下文中一共展示了DrawerLayout.SetDrawerListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
locationManager = GetSystemService(Context.LocationService) as LocationManager;
//set the user current location
setlocation();
//setup the map
SetupMap();
//set left drawer staff
leftDrawerLayaout = FindViewById<DrawerLayout>(Resource.Id.myDrawer);
leftDrawer = FindViewById<ListView>(Resource.Id.leftListView);
//get users
populateUsersOnDrawer();
leftDrawerToggle = new ActionBarDrawerToggle(this, leftDrawerLayaout, Resource.Drawable.menu, Resource.String.drawer_open, Resource.String.drawer_close);
leftDrawerLayaout.SetDrawerListener(leftDrawerToggle);
ActionBar.SetDisplayHomeAsUpEnabled(true);
ActionBar.SetHomeButtonEnabled(true);
ActionBar.SetDisplayShowTitleEnabled(true);
//start message service
StartService(new Intent(this, typeof(MsgApiService)));
}
示例2: OnCreate
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
SetContentView (Resource.Layout.Main);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
// Init toolbar
var toolbar = FindViewById<Toolbar>(Resource.Id.app_bar);
SetSupportActionBar(toolbar);
SupportActionBar.SetTitle (Resource.String.app_name);
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetDisplayShowHomeEnabled(true);
// Attach item selected handler to navigation view
var navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected;
// Create ActionBarDrawerToggle button and add it to the toolbar
var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.open_drawer, Resource.String.close_drawer);
drawerLayout.SetDrawerListener(drawerToggle);
drawerToggle.SyncState();
//load default home screen
var ft= FragmentManager.BeginTransaction ();
ft.AddToBackStack (null);
ft.Add (Resource.Id.HomeFrameLayout, new HomeFragment ());
ft.Commit ();
}
示例3: OnCreate
protected override void OnCreate (Android.OS.Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
SetContentView (Resource.Layout.Main);
Toolbar = FindViewById<Toolbar> (Resource.Id.toolbar);
drawerLayout = FindViewById<DrawerLayout> (Resource.Id.drawer_layout);
if (Toolbar != null) {
SetSupportActionBar (Toolbar);
SupportActionBar.SetDisplayHomeAsUpEnabled (true);
SupportActionBar.SetHomeButtonEnabled (true);
}
var navigationDrawer = this.FindViewById<NavigationView> (Resource.Id.nav_view);
navigationDrawer.NavigationItemSelected += Nv_NavigationItemSelected;
// animating menu
actionBarToggle = new ActionBarDrawerToggle (
this,
drawerLayout,
Resource.String.openDrawer,
Resource.String.closeDrawer
);
drawerLayout.SetDrawerListener (actionBarToggle);
actionBarToggle.SyncState ();
DoFirstRun (savedInstanceState);
}
示例4: InitUI
void InitUI()
{
mDrawerLayout = FindViewById<DrawerLayout> (Resource.Id.drawerLayout);
mDrawerList = FindViewById<ListView> (Resource.Id.sliderMenu);
var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, operations);
mDrawerList.Adapter = adapter;
ActionBar.SetDisplayHomeAsUpEnabled (true);
ActionBar.SetHomeButtonEnabled (true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
Resource.Drawable.ic_drawer, //nav menu toggle icon
Resource.String.app_name, // nav drawer open - description for accessibility
Resource.String.app_name // nav drawer close - description for accessibility
);
mDrawerLayout.DrawerClosed += (sender, e) => {
ActionBar.Title = Resources.GetString(Resource.String.app_name);
InvalidateOptionsMenu();
};
mDrawerLayout.DrawerOpened += (sender, e) => {
ActionBar.Title = Resources.GetString(Resource.String.app_name);
InvalidateOptionsMenu();
};
mDrawerLayout.SetDrawerListener(mDrawerToggle);
//FragmentManager.BeginTransaction ().Replace (Resource.Id.container, new ServiceFragment ()).Commit ();
//FragmentManager.BeginTransaction ().Replace (Resource.Id.container, new LinearFragment ()).Commit ();
FragmentManager.BeginTransaction ().Replace (Resource.Id.container, new EditTextSampleFragment ()).Commit ();
}
示例5: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
int calcNo = Intent.GetIntExtra("CalculationType",-1);
SetContentView (Resource.Layout.PercentDrawer);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerLayout);
drawerLayout.SetBackgroundColor(Android.Graphics.Color.AntiqueWhite);
ColorDrawable colorDrawable = new ColorDrawable (Color.Black);
this.ActionBar.SetBackgroundDrawable (colorDrawable);
drawerToggle = new ActionBarDrawerToggle (this, drawerLayout, Resource.String.DrawerOpenDescription, Resource.String.DrawerCloseDescription);
drawerLayout.SetDrawerListener (drawerToggle);
drawerListView = FindViewById<ListView> (Resource.Id.drawerListView);
drawerListView.Adapter = new ArrayAdapter<string> (this, Android.Resource.Layout.SimpleListItem1, calculationTitles);
drawerListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => OnMenuItemClick(e.Position);
drawerListView.SetItemChecked (calcNo, true);
OnMenuItemClick (calcNo);
ActionBar.SetDisplayHomeAsUpEnabled (true);
}
示例6: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
_logging.WriteLine(Lib.Logging.MessageType.Information, "Starting application in MainActivity OnCreate method");
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
SetContentView(Resource.Layout.Main);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerLayout);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, Resource.String.DrawerOpenDescription, Resource.String.DrawerCloseDescription);
drawerLayout.SetDrawerListener(drawerToggle);
ActionBar.SetIcon(Android.Resource.Color.Transparent);
ActionBar.SetDisplayHomeAsUpEnabled(true);
drawerListView = FindViewById<ListView>(Resource.Id.drawerListView);
menuAdapter = new MenuAdapter (this);
drawerListView.Adapter = menuAdapter;
drawerListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => OnMenuItemClick(e.Position);
var aboutFrag = menuAdapter.MenuItems.FirstOrDefault(x => x.Manager.GetType() == typeof(AboutFragment));
var aboutPos = menuAdapter.MenuItems.IndexOf (aboutFrag);
drawerListView.SetItemChecked(aboutPos, true); // Highlight the About Fragment at startup
OnMenuItemClick(aboutPos); // Load About Fragment at startup
}
示例7: OnCreate
//public List<DrawerItem> items;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
// Create your application here
SetContentView (Resource.Layout.activity_drawer_welcomeLayout);
try
{
mDrawerLayout = FindViewById<DrawerLayout> (Resource.Id.myDrawer_layout);
mLeftDrawer = FindViewById<ListView> (Resource.Id.leftListView);
mDrawerToggle = new myActionBarDrawerToggle (this, mDrawerLayout, Resource.Drawable.ic_drawer, Resource.String.open_drawer, Resource.String.close_drawer);
mLeftDrawer.Adapter=new MenuListAdapter(this);
this.mLeftDrawer.ItemClick += (sender, e) => SelectItem(e.Position);
mDrawerLayout.SetDrawerListener (mDrawerToggle);
ActionBar.SetDisplayHomeAsUpEnabled (true);
ActionBar.SetHomeButtonEnabled (true);
ActionBar.SetDisplayShowTitleEnabled (true);
}
catch (Exception ex) {
var toast = Toast.MakeText (this, ex.Message ,ToastLength.Short);
toast.Show ();
}
}
示例8: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
fragmentManager = FragmentManager;
//fragmentManager.AddOnBackStackChangedListener(this);
registerFragments(bundle);
SetContentView(Resource.Layout.activity_home);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer);
toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
if (toolbar != null)
{
SetSupportActionBar(toolbar);
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
drawerToggle = new MvxActionBarDrawerToggle(
this, /* host Activity */
drawerLayout, /* DrawerLayout object */
toolbar, /* nav drawer icon to replace 'Up' caret */
Resource.String.drawer_open, /* "open drawer" description */
Resource.String.drawer_close /* "close drawer" description */
);
drawerLayout.SetDrawerListener(drawerToggle);
}
ViewModel.ShowMenu ();
}
示例9: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource.
SetContentView(Resource.Layout.Main);
_DrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerMain);
// Set the toolbar
_Toolbar = FindViewById<SupportToolbar>(Resource.Id.toolbar);
_DrawerToggle = new HelpsAppCompatDrawerToggle(this, _DrawerLayout, Resource.String.menuTitle, _CurrentViewTitle);
_DrawerLayout.SetDrawerListener(_DrawerToggle);
// Set up action bar
SetUpSupportActionBar(bundle);
_DrawerToggle.SyncState();
// Set up the menu layout.
SetUpMenu();
//Fetch booking data
FetchBookingData();
}
示例10: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.main);
sections = Resources.GetTextArray(Resource.Array.drawer_sections);
currentSectionTitle = drawerTitle = Title;
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
drawerListView = FindViewById<ListView>(Resource.Id.left_drawer);
drawerListView.Adapter = new ArrayAdapter<string>(this, Resource.Layout.item_menu, sections);
drawerListView.ItemClick += (sender, args) => ListItemClicked(args.Position);
drawerLayout.SetDrawerShadow(Resource.Drawable.drawer_shadow_dark, (int)GravityFlags.Start);
//DrawerToggle is the animation that happens with the indicator next to the actionbar
drawerToggle = new DrawerToggle(this, drawerLayout,
Resource.Drawable.ic_drawer_light,
Resource.String.drawer_open,
Resource.String.drawer_close);
//Display the current fragments title and update the options menu
drawerToggle.DrawerClosed += (o, args) =>
{
ActionBar.Title = currentSectionTitle;
InvalidateOptionsMenu();
};
//Display the drawer title and update the options menu
drawerToggle.DrawerOpened += (o, args) =>
{
ActionBar.Title = drawerTitle;
InvalidateOptionsMenu();
};
//Set the drawer lister to be the toggle.
drawerLayout.SetDrawerListener(drawerToggle);
//If first time you will want to go ahead and click first item.
if (savedInstanceState == null)
{
ListItemClicked(0);
}
ActionBar.SetDisplayHomeAsUpEnabled(true);
ActionBar.SetHomeButtonEnabled(true);
}
示例11: SetupNavigationDrawer
void SetupNavigationDrawer()
{
SupportActionBar.SetDisplayHomeAsUpEnabled (true);
SupportActionBar.SetHomeButtonEnabled (true);
NavigationDrawer = FindViewById<DrawerLayout> (Resource.Id.NavigationDrawer);
DrawerToggle = new ActionBarDrawerToggle (this, NavigationDrawer, Toolbar,
Resource.String.label_open_navigation, Resource.String.label_close_navigation);
NavigationDrawer.SetDrawerListener (DrawerToggle);
DrawerToggle.SyncState ();
}
示例12: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
_title = _drawerTitle = Title;
_planetTitles = Resources.GetStringArray(Resource.Array.PlanetsArray);
_drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
_drawerList = FindViewById<ListView>(Resource.Id.left_drawer);
_drawer.SetDrawerShadow(Resource.Drawable.drawer_shadow_dark, (int)GravityFlags.Start);
_drawerList.Adapter = new ArrayAdapter<string>(this,
Resource.Layout.DrawerListItem, _planetTitles);
_drawerList.ItemClick += (sender, args) => SelectItem(args.Position);
ActionBar.SetDisplayHomeAsUpEnabled(true);
ActionBar.SetHomeButtonEnabled(true);
//DrawerToggle is the animation that happens with the indicator next to the
//ActionBar icon. You can choose not to use this.
_drawerToggle = new MyActionBarDrawerToggle(this, _drawer,
Resource.Drawable.ic_drawer_light,
Resource.String.DrawerOpen,
Resource.String.DrawerClose);
//You can alternatively use _drawer.DrawerClosed here
_drawerToggle.DrawerClosed += delegate
{
ActionBar.Title = _title;
InvalidateOptionsMenu();
};
//You can alternatively use _drawer.DrawerOpened here
_drawerToggle.DrawerOpened += delegate
{
ActionBar.Title = _drawerTitle;
InvalidateOptionsMenu();
};
_drawer.SetDrawerListener(_drawerToggle);
if (null == savedInstanceState)
SelectItem(0);
}
示例13: OnCreate
#pragma warning restore 414
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.HomeView);
mDrawerLayout = FindViewById<DrawerLayout> (Resource.Id.drawer);
mDrawerView = FindViewById (Resource.Id.items);
mDrawerToggle = new ActionBarDrawerToggle (this, mDrawerLayout, Resource.Drawable.ic_navigation_drawer, 0, 0);
mDrawerLayout.SetDrawerListener (mDrawerToggle);
ActionBar.SetHomeButtonEnabled (true);
ActionBar.SetDisplayHomeAsUpEnabled (true);
_closeDrawerToken = Mvx.Resolve<IMvxMessenger> ().SubscribeOnMainThread<CloseDrawerMessage> (
message => mDrawerLayout.CloseDrawer (mDrawerView));
}
示例14: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.MySoal_MainPager);
adapter = new MySoal_ViewPagerAdapter (SupportFragmentManager);
mDrawerLayout = FindViewById<DrawerLayout> (Resource.Id.myDrawer);
mDrawerToggle = new Android.Support.V7.App.ActionBarDrawerToggle (this, mDrawerLayout, Resource.String.open_drawer, Resource.String.close_drawer);
mDrawerLayout.SetDrawerListener (mDrawerToggle);
leftListView = (LinearLayout)FindViewById (Resource.Id.leftListView);
lvMMLListed = (ListView)FindViewById (Resource.Id.lvMMLListed);
pager = FindViewById <ViewPager> (Resource.Id.pager);
pager.Adapter = adapter;
tabs = FindViewById<MySoal_SlidingTabScrollView> (Resource.Id.tabs);
tabs.ViewPager = pager;
toolbar = FindViewById<Android.Support.V7.Widget.Toolbar> (Resource.Id.app_bar);
toolbar.SetBackgroundColor (Color.ParseColor ("#F44336"));
SetSupportActionBar (toolbar);
SupportActionBar.SetDisplayHomeAsUpEnabled (true);
SupportActionBar.SetHomeButtonEnabled (true);
SupportActionBar.SetDisplayShowTitleEnabled (true);
MenuListItem = new List<LeftMenuListItems> ();
MenuListItem.Add (new LeftMenuListItems(){
LeftMenuDrawerLabel = "Dashboard",
LeftMenuDrawerIconID = Resource.Drawable.home3 });
MenuListItem.Add (new LeftMenuListItems(){
LeftMenuDrawerLabel = "My Soal",
LeftMenuDrawerIconID = Resource.Drawable.cup2 });
MenuListItem.Add (new LeftMenuListItems(){
LeftMenuDrawerLabel = "My Health",
LeftMenuDrawerIconID = Resource.Drawable.heart2 });
MenuListItem.Add (new LeftMenuListItems(){
LeftMenuDrawerLabel = "My Skool",
LeftMenuDrawerIconID = Resource.Drawable.shield2 });
lvMMLListed.Adapter = new MainActivityAdapters (this, MenuListItem);
}
示例15: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
// Init toolbar
var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
SetSupportActionBar(toolbar);
// Attach item selected handler to navigation view
var navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected;
// Create ActionBarDrawerToggle button and add it to the toolbar
var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.open_drawer, Resource.String.close_drawer);
drawerLayout.SetDrawerListener(drawerToggle);
drawerToggle.SyncState();
}