Skip to content

Instantly share code, notes, and snippets.

@dsibinski
Created May 9, 2017 21:31
Show Gist options
  • Save dsibinski/621414dcb86e331e87b0ffd12939df1b to your computer and use it in GitHub Desktop.
Save dsibinski/621414dcb86e331e87b0ffd12939df1b to your computer and use it in GitHub Desktop.
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