Reputation: 2783
I am using the ThriveGmbH.BottomNavigationBar.XF
Nuget package to add a bottom tab bar to my application
BottomBarPage bottomBar = new BottomBarPage
{
};
var tab1 = new MainPage();
var tab2 = new ReceivePage(null);
var tab3 = new SendPage(false);
var tab4 = new SendPage(false);
var tab5 = new InfoPage(null);
bottomBar.Children.Add(tab1);
bottomBar.Children.Add(tab2);
bottomBar.Children.Add(tab3);
bottomBar.Children.Add(tab4);
bottomBar.Children.Add(tab5);
How do I add a listener to this BottomBarPage
which checks which of the tabs is currently selected, so that I can add the code below to this listener.
if (bottomBar.SelectedItem == bottomBar.Children[3])
{
//do something
}
Upvotes: 1
Views: 409
Reputation: 352
Use Android.Support.Design.Widget.TabLayout to create a tabLayout object and create Tab Item elements nested inside a Tab Layout element in your XML.
You can use a TabSelected event on this object like so:
tabLayout.TabSelected += OnTabSelected
Then you can write your OnTabSelected code.
Upvotes: 2