本文整理汇总了C#中DrawerLayout.CloseDrawers方法的典型用法代码示例。如果您正苦于以下问题:C# DrawerLayout.CloseDrawers方法的具体用法?C# DrawerLayout.CloseDrawers怎么用?C# DrawerLayout.CloseDrawers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawerLayout
的用法示例。
在下文中一共展示了DrawerLayout.CloseDrawers方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setupNavigationView
protected void setupNavigationView(NavigationView navigationView)
{
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
if (navigationView != null)
{
navigationView.NavigationItemSelected += (sender, e) => {
e.MenuItem.SetChecked (true);
drawerLayout.CloseDrawers ();
};
}
}
示例2: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var config = ImageLoaderConfiguration.CreateDefault(ApplicationContext);
// Initialize ImageLoader with configuration.
ImageLoader.Instance.Init(config);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
navigationView.NavigationItemSelected += (sender, e) =>
{
if (previousItem != null)
previousItem.SetChecked(false);
navigationView.SetCheckedItem(e.MenuItem.ItemId);
previousItem = e.MenuItem;
switch (e.MenuItem.ItemId)
{
case Resource.Id.nav_home:
ListItemClicked(0);
break;
case Resource.Id.nav_friends:
ListItemClicked(1);
break;
case Resource.Id.nav_profile:
ListItemClicked(2);
break;
}
drawerLayout.CloseDrawers();
};
//if first time you will want to go ahead and click first item.
if (savedInstanceState == null)
{
ListItemClicked(0);
navigationView.SetCheckedItem(Resource.Id.nav_home);
}
}
示例3: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
drawerLayout = this.FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
//Set hamburger items menu
SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
//setup navigation view
navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
//handle navigation
navigationView.NavigationItemSelected += (sender, e) =>
{
if (previousItem != null)
previousItem.SetChecked(false);
navigationView.SetCheckedItem(e.MenuItem.ItemId);
previousItem = e.MenuItem;
switch (e.MenuItem.ItemId)
{
case Resource.Id.nav_home_1:
ListItemClicked(0);
break;
case Resource.Id.nav_home_2:
ListItemClicked(1);
break;
}
drawerLayout.CloseDrawers();
};
//if first time you will want to go ahead and click first item.
if (savedInstanceState == null)
{
navigationView.SetCheckedItem(Resource.Id.nav_home_1);
ListItemClicked(0);
}
}
示例4: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.dash_layout);
var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar> (Resource.Id.toolbar);
SetSupportActionBar (toolbar);
SupportActionBar.SetDisplayHomeAsUpEnabled (true);
SupportActionBar.SetHomeAsUpIndicator (Resource.Drawable.ic_menu);
drawerlayout = FindViewById<DrawerLayout> (Resource.Id.drawer_layout);
navigationView = FindViewById<NavigationView> (Resource.Id.nav_view);
navigationView.NavigationItemSelected += (sender, e) => {
e.MenuItem.SetChecked (true);
drawerlayout.CloseDrawers ();
};
}
示例5: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
#if !XTC
InitializeHockeyApp();
#endif
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
//Set hamburger items menu
SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
//setup navigation view
navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
//handle navigation
navigationView.NavigationItemSelected += (sender, e) =>
{
e.MenuItem.SetChecked(true);
ListItemClicked(e.MenuItem.ItemId);
SupportActionBar.Title = e.MenuItem.ItemId == Resource.Id.menu_profile
? Settings.Current.UserFirstName
: e.MenuItem.TitleFormatted.ToString();
drawerLayout.CloseDrawers();
};
if (Intent.GetBooleanExtra("tracking", false))
{
ListItemClicked(Resource.Id.menu_current_trip);
SupportActionBar.Title = "Current Trip";
return;
}
//if first time you will want to go ahead and click first item.
if (bundle == null)
{
ListItemClicked(Resource.Id.menu_current_trip);
SupportActionBar.Title = "Current Trip";
}
}
示例6: OnCreate
protected override async void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var dbPath = Path.Combine(path, "counters.db3");
DatabaseHelper.CreateDatabase(dbPath);
await ViewModelLocator.Counters.LoadCountersAsync();
_drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
//Set hamburger items menu
SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
//setup navigation view
_navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
//handle navigation
_navigationView.NavigationItemSelected += (sender, e) =>
{
e.MenuItem.SetChecked(true);
switch (e.MenuItem.ItemId)
{
case Resource.Id.nav_counters:
ListItemClicked(0);
break;
case Resource.Id.nav_about:
ListItemClicked(1);
break;
}
_drawerLayout.CloseDrawers();
};
//if first time you will want to go ahead and click first item.
if (savedInstanceState == null)
{
ListItemClicked(0);
}
}
示例7: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
drawerLayout = this.FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
//Set hamburger items menu
SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
//setup navigation view
navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
//handle navigation
navigationView.NavigationItemSelected += (sender, e) =>
{
e.MenuItem.SetChecked(true);
switch (e.MenuItem.ItemId)
{
case Resource.Id.nav_home_1:
ListItemClicked(0);
break;
case Resource.Id.nav_home_2:
ListItemClicked(1);
break;
}
Snackbar.Make(drawerLayout, "You selected: " + e.MenuItem.TitleFormatted, Snackbar.LengthLong)
.Show();
drawerLayout.CloseDrawers();
};
//if first time you will want to go ahead and click first item.
if (savedInstanceState == null)
{
ListItemClicked(0);
}
}
示例8: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
Xamarin.Insights.Initialize (BO.Insights.ApiKey, this);
base.OnCreate (savedInstanceState);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
navigationView.NavigationItemSelected += (sender, e) => {
e.MenuItem.SetChecked(true);
switch (e.MenuItem.ItemId)
{
case Resource.Id.nav_Resultados:
ListItemClicked(0);
break;
case Resource.Id.nav_CrearGrupo:
ListItemClicked(1);
break;
case Resource.Id.nav_MisGrupos:
ListItemClicked(2);
break;
case Resource.Id.nav_estadisticas:
ListItemClicked(3);
break;
}
drawerLayout.CloseDrawers();
};
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button> (Resource.Id.myButton);
}
示例9: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
navigationView.NavigationItemSelected += (sender, e) =>
{
e.MenuItem.SetChecked(true);
switch (e.MenuItem.ItemId)
{
case Resource.Id.nav_home:
ListItemClicked(0);
break;
case Resource.Id.nav_profile:
ListItemClicked(2);
break;
}
drawerLayout.CloseDrawers();
};
//if first time you will want to go ahead and click first item.
if (savedInstanceState == null)
{
ListItemClicked(0);
}
OnNewIntent(Intent);
}
示例10: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
if (!CheckInternetConnectivity())
{
Toast.MakeText(this, "YOU ARE OFFLINE!", ToastLength.Short).Show();
//Finish();
//Process.KillProcess(Android.OS.Process.MyPid());
}
else
{
if (!DataRepository.HaveData)
{
var progressDialog = ProgressDialog.Show(this, "Please wait...", "Getting data...", true);
new Thread(new ThreadStart(delegate
{
DataRepository.GetData();
DataRepository.SortData();
RunOnUiThread(AfterDataFetching);
RunOnUiThread(() => progressDialog.Hide());
})).Start();
}
}
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
//Set hamburger items menu
SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
//setup navigation view
navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
//handle navigation
navigationView.NavigationItemSelected += (sender, e) =>
{
e.MenuItem.SetChecked(true);
switch (e.MenuItem.ItemId)
{
case Resource.Id.productsMenuItem:
ListItemClicked(0);
break;
case Resource.Id.selectedProductsMenuItem:
ListItemClicked(1);
break;
case Resource.Id.aboutMenuItem:
ListItemClicked(2);
break;
}
drawerLayout.CloseDrawers();
};
//if first time you will want to go ahead and click first item.
if (savedInstanceState == null)
{
ListItemClicked(0);
}
}
示例11: OnCreate
//.........这里部分代码省略.........
try{
SupportActionBar.Title = "Inicio";
Log.Debug (tag, "pasamos el title igual a inicio");
}catch(Exception ex){
Log.Debug (tag, "El error del action bar title fue:" + ex + "ACABA ERROR");
}
try{
SupportActionBar.SetHomeAsUpIndicator (Resource.Drawable.ic_menu);
SupportActionBar.SetDisplayHomeAsUpEnabled (true);
SupportActionBar.SetHomeButtonEnabled (true);
Log.Debug (tag, "pasamos TODOS los support action bar");
}
catch(Exception ex){
Log.Debug (tag, "El error del alguno de los suportactionbar fue:" + ex + "ACABA ERROR");
}
try{
drawerLayout = FindViewById<DrawerLayout> (Resource.Id.drawer_layout);
Log.Debug (tag, "pasamos asignar drawerlayout");
}catch(Exception ex){
Log.Debug (tag, "El error deasignar el drawer layout fue" + ex + "ACABA ERROR");
}
navigationView = FindViewById<NavigationView> (Resource.Id.nav_view);
//AQUI ES DONDE CAMBIA SEGUN EL ELEMENTO DEL MENU QUE ELIJAS
try{
navigationView.NavigationItemSelected += (sender, e) =>
{
e.MenuItem.SetChecked (true);
SupportActionBar.Title = e.MenuItem.TitleFormatted.ToString();
drawerLayout.CloseDrawers ();
if(e.MenuItem.TitleFormatted.ToString() == "Inicio")
{
ReplaceFragment (mFragment1);
}
else if(e.MenuItem.TitleFormatted.ToString() == "Buscar")
{
gpsclass.PutString ("region", "nada");
ReplaceFragment (mFragment2);
}
else if(e.MenuItem.TitleFormatted.ToString() == "Últimos Negocios")
{
ReplaceFragment (mFragment3);
}
else if(e.MenuItem.TitleFormatted.ToString() == "Añadir Negocios")
{
//ReplaceFragment (mFragment4);
//Toast.MakeText (this, "Próximamente...", ToastLength.Long).Show ();
Log.Debug("Añadir Negocio","Hizo click!");
var nuevoneg = new Intent (this, typeof(AgregarNegocio));
/*enviarmsj.PutExtra("negocioid",idres);
enviarmsj.PutExtra("titulo", titulores);
enviarmsj.PutExtra("propietario",propietario);*/
StartActivity (nuevoneg);
}
else if(e.MenuItem.TitleFormatted.ToString() == "Cerrar Sesión")
{
var Dialog = new Android.Support.V7.App.AlertDialog.Builder(this);
Dialog.SetTitle("Cerrar Sesión");
Dialog.SetMessage("¿Desea cerrar la sesión?");
Dialog.SetPositiveButton("Cerrar Sesión",delegate
{
editor.Clear ();
示例12: NaviView
private void NaviView()
{
// 서랍 메뉴
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
navigationView.NavigationItemSelected += (sender, e) =>
{
e.MenuItem.SetChecked(true);
bool ret;
switch (e.MenuItem.ItemId) {
case Resource.Id.nav_weld_count:
viewPager.SetCurrentItem(1, true);
break;
case Resource.Id.nav_weld_condition:
viewPager.SetCurrentItem(2, true);
break;
case Resource.Id.nav_storage:
viewPager.SetCurrentItem(0, true);
if (!StorageRefresh("/storage"))
Show("경로 이동 실패: " + "/storage");
break;
case Resource.Id.nav_sdcard0:
viewPager.SetCurrentItem(0, true);
if (!StorageRefresh(Environment.ExternalStorageDirectory.AbsolutePath))
Show("경로 이동 실패: " + Environment.ExternalStorageDirectory.AbsolutePath);
break;
case Resource.Id.nav_extsdcard:
viewPager.SetCurrentItem(0, true);
ret = false;
try {
var dir = new DirectoryInfo("/storage");
foreach (var item in dir.GetDirectories()) {
if (item.Name.ToLower().StartsWith("ext") || item.Name.ToLower().StartsWith("sdcard1")) {
foreach (var subItem in item.GetFileSystemInfos()) {
if (StorageRefresh(item.FullName)) {
ret = true;
break;
}
}
}
}
} catch { }
if (!ret)
Show("경로 이동 실패: " + "SD 카드");
break;
case Resource.Id.nav_usbstorage:
viewPager.SetCurrentItem(0, true);
ret = false;
try {
var dir = new DirectoryInfo("/storage");
foreach (var item in dir.GetDirectories()) {
if (item.Name.ToLower().StartsWith("usb")) {
foreach (var subItem in item.GetFileSystemInfos()) {
if (StorageRefresh(item.FullName)) {
ret = true;
break;
}
}
}
}
} catch { }
if (!ret)
Show("경로 이동 실패: " + "USB 저장소");
break;
case Resource.Id.nav_exit:
Finish();
break;
}
drawerLayout.CloseDrawers();
};
NaviViewHeader();
}
示例13: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Encrypt);
var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
SetSupportActionBar(toolbar);
SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_action_nav_menu_holo_dark);
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
switchForceUnicode = FindViewById<Switch>(Resource.Id.switchForceUnicode);
switchEncodeTextEncode = FindViewById<Switch>(Resource.Id.switchEncodeTextEncode);
var listView1 = FindViewById<ScrollView>(Resource.Id.listView1);
listView1.Visibility = ViewStates.Gone;
Spinner spinnerEncodeType = FindViewById<Spinner>(Resource.Id.spinnerEncodeType);
spinnerEncodeType.Adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, EncodeType);
spinnerEncodeType.ItemSelected += (sender, e) => {
if (e.Position == 1) {
listView1.Visibility = ViewStates.Visible;
}
else
{
listView1.Visibility = ViewStates.Gone;
}
};
EditText editTextOrigin = FindViewById<EditText>(Resource.Id.editTextO);
EditText editTextEncode = FindViewById<EditText>(Resource.Id.editTextE);
Button butEncode = FindViewById<Button>(Resource.Id.butEncode);
Button butDecode = FindViewById<Button>(Resource.Id.butDecode);
butEncode.Click += (sender, e) => {
switch (EncodeType[spinnerEncodeType.SelectedItemPosition])
{
case "crmkjk":
editTextEncode.Text = CRMKJK.CRMKJK.EncodeEasy(editTextOrigin.Text, (switchForceUnicode.Checked ? CRMKJKState.Unicode : 0) | (switchEncodeTextEncode.Checked ? CRMKJKState.EncodeTextB64Encode : 0));
break;
case "base64":
if (string.IsNullOrWhiteSpace(editTextOrigin.Text)) return;
editTextEncode.Text = Convert.ToBase64String(Encoding.Default.GetBytes(editTextOrigin.Text));
break;
case "unicode":
editTextEncode.Text = editTextOrigin.Text.EscapeToUnicode();
break;
default:
break;
}
};
butDecode.Click += (sender, e) => {
switch (EncodeType[spinnerEncodeType.SelectedItemPosition])
{
case "crmkjk":
try
{
editTextOrigin.Text = CRMKJK.CRMKJK.Decode(editTextEncode.Text);
}
catch (UnexpectedCRMKJKEncodeException)
{
Toast.MakeText(this, "ERROR: unexpected crmkjk encode", ToastLength.Short).Show();
}
break;
case "base64":
if (string.IsNullOrWhiteSpace(editTextEncode.Text)) return;
try
{
editTextOrigin.Text = Encoding.Default.GetString(Convert.FromBase64String(editTextEncode.Text));
}
catch (FormatException)
{
Toast.MakeText(this, "ERROR: unexpected base64 encode", ToastLength.Short).Show();
}
break;
case "unicode":
if (string.IsNullOrWhiteSpace(editTextEncode.Text)) return;
try
{
editTextOrigin.Text = editTextEncode.Text.TrapToUnicode();
}
catch (FormatException)
{
Toast.MakeText(this, "ERROR: unexpected unicode", ToastLength.Short).Show();
}
break;
default:
break;
}
};
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
var navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
navigationView.NavigationItemSelected += (sender, e) => {
e.MenuItem.SetChecked(true);
//react to click here and swap fragments or navigate
drawerLayout.CloseDrawers();
if (e.MenuItem.ItemId == Resource.Id.nav_imgedit)
{
//.........这里部分代码省略.........
示例14: OnCreate
//Pass title here in on Create???? Seems like cheap work around but could work
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.base_activity_layout);
_Toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
SetSupportActionBar(_Toolbar);
_BaseFrameLayout = FindViewById<FrameLayout>(Resource.Id.content_frame);
_DrawerLayout = FindViewById<DrawerLayout>(Resource.Id.test_drawer_layout);
_navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
UserTextView = FindViewById<TextView>(Resource.Id.headerTextView);
UserTextView.Click += delegate
{
Console.WriteLine("I clicked on user");
};
UpdateCurrentUser();
_navigationView.SetCheckedItem(Resource.Id.navigation_item_1);
_navigationView.NavigationItemSelected += (sender, args) =>
{
if (args.MenuItem.ItemId != _currentSelectedId)
{
_DrawerLayout.CloseDrawers();
Console.WriteLine("Menu Item clicked is " + args.MenuItem.ItemId);
Console.WriteLine("Item 3 ID is " +
_navigationView.Menu.FindItem(Resource.Id.GoToTestSecondActivity).ItemId);
if (args.MenuItem.ItemId == _navigationView.Menu.FindItem(Resource.Id.GoToTestSecondActivity).ItemId)
{
StartActivity(typeof (TrakkedShowsTabActivity));
}
if (args.MenuItem.ItemId == _navigationView.Menu.FindItem(Resource.Id.GoToTrakkedShowsActivity).ItemId)
{
}
if (args.MenuItem.ItemId == _navigationView.Menu.FindItem(Resource.Id.GoToAddShowActivity).ItemId)
{
StartActivity(typeof (AddShowActivity));
}
if (args.MenuItem.ItemId == _navigationView.Menu.FindItem(Resource.Id.GoToAddMoviesActivity).ItemId)
{
StartActivity(typeof(AddMovieActivity));
}
}
//args.MenuItem.SetChecked(true);
};
_navigationView.Menu.FindItem(Resource.Id.navigation_item_2).SetTitle("Logout");
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
SetTitle("BaseActivity");
}