Search code examples
c#androidxamarinbottomnavigationview

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

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 :/


Solution

  • I am using NavigationView but I saw the same methods on BottomNavigationView (I declared it on my code). 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);