How to implement the new SetOnItemSelectedListener for bottom navigation bar in Xamarin Android

572 Views Asked by At

I upgrade my Xamarin Android to API 30 and began getting errors with the old code below that implements SetOnNavigationItemSelectedListener. I am now trying to implement the new SetOnItemSelectedListener, but do not know how too. Any ideas?

bottomNavigation = FindViewById<BottomNavigationView>(Resource.Id.navigation);                         
                    bottomNavigation.SetOnNavigationItemSelectedListener(this);
                    bottomNavigation.NavigationItemSelected += Navigation_NavigationItemSelected;
1

There are 1 best solutions below

0
Blackie On

To use the new BottomNavigationVIew in Xamarin.Google.Android.Material -Version 1.4.0.4 use the IOnItemSelectedListener Interface on your class then use the code below.

    bottomNavigation = (BottomNavigationView)FindViewById(Resource.Id.bottom_navigation);

bottomNavigation.ItemSelected += BottomNavigation_ItemSelected;