Skip to content

Instantly share code, notes, and snippets.

@topgenorth
Created July 24, 2013 17:23
Show Gist options
  • Save topgenorth/6072607 to your computer and use it in GitHub Desktop.
Save topgenorth/6072607 to your computer and use it in GitHub Desktop.
Sample ActionBar code
private void InitializeActionBar()
{
ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
var firstTab = SetupGraffitiGridTab();
SetupGraffitiMapTab();
ActionBar.SelectTab(firstTab);
}
private ActionBar.Tab SetupGraffitiGridTab()
{
_graffittiGridTab = ActionBar.NewTab();
_graffittiGridTab.SetText(Resources.GetString(Resource.String.tab_text_list));
_graffittiGridTab.SetIcon(Resource.Drawable.ic_action_graffiti_list);
_graffittiGridTab.TabSelected += (sender, args) => { DisplayGraffitiGrid(); };
ActionBar.AddTab(_graffittiGridTab);
return _graffittiGridTab;
}
private void SetupGraffitiMapTab()
{
_mapTab = ActionBar.NewTab();
_mapTab.SetText(Resources.GetString(Resource.String.tab_text_maptab));
_mapTab.SetIcon(Resource.Drawable.ic_action_graffiti_map);
_mapTab.TabSelected += (sender, args) => { _viewModel.DisplayAllInMap(this, _locationHelper.LastLocation); };
ActionBar.AddTab(_mapTab);
}
@topgenorth
Copy link
Author

Also need to have this line in OnCreate:

RequestWindowFeature(WindowFeatures.ActionBar);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment