Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
void AddTab(string tabText, Fragment view)
{
var tab = this.ActionBar.NewTab();
tab.SetText(tabText);
tab.TabSelected += delegate (object sender, ActionBar.TabEventArgs e)
{
var fragment = this.FragmentManager.FindFragmentById(Resource.Id.tabFragmentsContainer);
if (fragment != null)
e.FragmentTransaction.Remove(fragment);
e.FragmentTransaction.Add(Resource.Id.tabFragmentsContainer, view);
};
tab.TabUnselected += delegate (object sender, ActionBar.TabEventArgs e) {
e.FragmentTransaction.Remove(view);
};
this.ActionBar.AddTab(tab);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment