简体   繁体   English

如何在Xamarin Android中禁用底部导航视图?

[英]How to disable bottom navigation view in xamarin android?

I'm trying to disable my bottom navigation view in my activity but it didn't work. 我正在尝试在活动中禁用我的底部导航视图,但这没有用。 But when i try to hide it and show it, its worked fine. 但是,当我尝试隐藏它并显示它时,它的效果很好。 But to disable and enable it, it doesn't work. 但是禁用和启用它不起作用。 Btw I used android.support.design.widget.BottomNavigationView 顺便说一句我用了android.support.design.widget.BottomNavigationView

This is the code i tried 这是我尝试的代码

BottomNavigationView bottomNavView = FindViewById<BottomNavigationView>(Resource.Id.bottom_navigation);

bottomNavView.Enable = true;

its not working and i don't know why :/ 它不起作用,我不知道为什么:/

I am using NavigationView but I saw the same methods on BottomNavigationView (I declared it on my code). 我正在使用NavigationView,但是在BottomNavigationView上看到了相同的方法(我在代码中声明了它)。 To disable the item you can do this: 要禁用该项目,您可以执行以下操作:

navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);//My navigationview
IMenuItem asd = (IMenuItem)navigationView.Menu.GetItem(2);
asd.SetEnabled(false);

If you want to remove items you can do this: 如果要删除项目,可以执行以下操作:

navigationView.Menu.RemoveItem(Resource.Id.nav_Cambiar_TPK);
navigationView.Menu.RemoveItem(Resource.Id.nav_nuevo);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM