Android Guides | Samples

Android.App.ActionBar Class

A primary toolbar within the activity that may display the activity title, application-level navigation affordances, and other interactive items.

See Also: ActionBar

Syntax

[Android.Runtime.Register("android/app/ActionBar", DoNotGenerateAcw=true)]
public abstract class ActionBar : Object

Remarks

A primary toolbar within the activity that may display the activity title, application-level navigation affordances, and other interactive items.

Developer Guides

Beginning with Android 3.0 (API level 11), the action bar appears at the top of an activity's window when the activity uses the system's NoType:android/R$style;Href=../../../reference/android/R.style.html#Theme_Holo theme (or one of its descendant themes), which is the default. You may otherwise add the action bar by calling Window.RequestFeature(WindowFeatures) or by declaring it in a custom theme with the NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#Theme_windowActionBar property.

Beginning with Android L (API level 21), the action bar may be represented by any Toolbar widget within the application layout. The application may signal to the Activity which Toolbar should be treated as the Activity's action bar. Activities that use this feature should use one of the supplied .NoActionBar themes, set the NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#Theme_windowActionBar attribute to false or otherwise not request the window feature.

By adjusting the window features requested by the theme and the layouts used for an Activity's content view, an app can use the standard system action bar on older platform releases and the newer inline toolbars on newer platform releases. The ActionBar object obtained from the Activity can be used to control either configuration transparently.

When using the Holo themes the action bar shows the application icon on the left, followed by the activity title. If your activity has an options menu, you can make select items accessible directly from the action bar as "action items". You can also modify various characteristics of the action bar or remove it completely.

When using the Material themes (default in API 21 or newer) the navigation button (formerly "Home") takes over the space previously occupied by the application icon. Apps wishing to express a stronger branding should use their brand colors heavily in the action bar and other application chrome or use a ActionBar.SetLogo(Int32) in place of their standard title text.

From your activity, you can retrieve an instance of ActionBar by calling Activity.ActionBar.

In some cases, the action bar may be overlayed by another bar that enables contextual actions, using an ActionMode. For example, when the user selects one or more items in your activity, you can enable an action mode that offers actions specific to the selected items, with a UI that temporarily replaces the action bar. Although the UI may occupy the same space, the ActionMode APIs are distinct and independent from those for ActionBar.

For information about how to use the action bar, including how to add action items, navigation modes and more, read the Action Bar developer guide.

[Android Documentation]

Requirements

Namespace: Android.App
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 11

The members of Android.App.ActionBar are listed below.

See Also: Object

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

abstract
CustomViewView.
abstract
DisplayOptionsActionBarDisplayOptions.
ElevationSingle. Get the Z-axis elevation of the action bar in pixels.
[read-only]
abstract
HeightInt32. Retrieve the current height of the ActionBar.
HideOffsetInt32. Return the current vertical offset of the action bar.
HideOnContentScrollEnabledBoolean. Return whether the action bar is configured to scroll out of sight along with a View.NestedScrollingEnabled.
[read-only]
abstract
IsShowingBoolean.
[read-only]
abstract
NavigationItemCountInt32. Get the number of navigation items present in the current navigation mode.
abstract
NavigationModeActionBarNavigationMode. Returns the current navigation mode.
[read-only]
abstract
SelectedNavigationIndexInt32. Get the position of the selected navigation item in list or tabbed navigation modes.
[read-only]
abstract
SelectedTabActionBar+Tab. Returns the currently selected tab if in tabbed navigation mode and there is at least one tab present.
SubtitleString.
abstract
SubtitleFormattedICharSequence. Returns the current ActionBar subtitle in standard mode.
[read-only]
abstract
TabCountInt32. Returns the number of tabs currently registered with the action bar.
[read-only]
ThemedContextContext. Returns a Context with an appropriate theme for creating views that will appear in the action bar.
TitleString.
abstract
TitleFormattedICharSequence. Returns the current ActionBar title in standard mode.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

abstract
AddOnMenuVisibilityListener(ActionBar+IOnMenuVisibilityListener)
Add a listener that will respond to menu visibility change events.
abstract
AddTab(ActionBar+Tab)
Add a tab for use in tabbed navigation mode.
abstract
AddTab(ActionBar+Tab, Boolean)
Add a tab for use in tabbed navigation mode.
abstract
AddTab(ActionBar+Tab, Int32)
Add a tab for use in tabbed navigation mode.
abstract
AddTab(ActionBar+Tab, Int32, Boolean)
Add a tab for use in tabbed navigation mode.
abstract
GetTabAt(Int32) : ActionBar+Tab
Returns the tab at the specified index.
abstract
Hide()
Hide the ActionBar if it is currently showing.
abstract
NewTab() : ActionBar+Tab
Create and return a new NoType:android/app/ActionBar$Tab;Href=../../../reference/android/app/ActionBar.Tab.html.
abstract
RemoveAllTabs()
Remove all tabs from the action bar and deselect the current tab.
abstract
RemoveOnMenuVisibilityListener(ActionBar+IOnMenuVisibilityListener)
Remove a menu visibility listener.
abstract
RemoveTab(ActionBar+Tab)
Remove a tab from the action bar.
abstract
RemoveTabAt(Int32)
Remove a tab from the action bar.
abstract
SelectTab(ActionBar+Tab)
Select the specified tab.
abstract
SetBackgroundDrawable(Drawable)
Set the ActionBar's background.
abstract
SetCustomView(Int32)
Set the action bar into custom navigation mode, supplying a view for custom navigation.
abstract
SetCustomView(View, ActionBar+LayoutParams)
Set the action bar into custom navigation mode, supplying a view for custom navigation.
abstract
SetDisplayHomeAsUpEnabled(Boolean)
Set whether home should be displayed as an "up" affordance.
abstract
SetDisplayOptions(ActionBarDisplayOptions, ActionBarDisplayOptions)
Set selected display options.
abstract
SetDisplayShowCustomEnabled(Boolean)
Set whether a custom view should be displayed, if set.
abstract
SetDisplayShowHomeEnabled(Boolean)
Set whether to include the application home affordance in the action bar.
abstract
SetDisplayShowTitleEnabled(Boolean)
Set whether an activity title/subtitle should be displayed.
abstract
SetDisplayUseLogoEnabled(Boolean)
Set whether to display the activity logo rather than the activity icon.
SetHomeActionContentDescription(ICharSequence)
Set an alternate description for the Home/Up action, when enabled.
SetHomeActionContentDescription(Int32)
Set an alternate description for the Home/Up action, when enabled.
SetHomeActionContentDescription(String)
SetHomeAsUpIndicator(Drawable)
Set an alternate drawable to display next to the icon/logo/title when ActionBar.DISPLAY_HOME_AS_UP is enabled.
SetHomeAsUpIndicator(Int32)
Set an alternate drawable to display next to the icon/logo/title when ActionBar.DISPLAY_HOME_AS_UP is enabled.
SetHomeButtonEnabled(Boolean)
Enable or disable the "home" button in the corner of the action bar.
abstract
SetIcon(Drawable)
Set the icon to display in the 'home' section of the action bar.
abstract
SetIcon(Int32)
Set the icon to display in the 'home' section of the action bar.
abstract
SetListNavigationCallbacks(ISpinnerAdapter, ActionBar+IOnNavigationListener)
Set the adapter and navigation callback for list navigation mode.
abstract
SetLogo(Drawable)
Set the logo to display in the 'home' section of the action bar.
abstract
SetLogo(Int32)
Set the logo to display in the 'home' section of the action bar.
abstract
SetSelectedNavigationItem(Int32)
Set the selected navigation item in list or tabbed navigation modes.
SetSplitBackgroundDrawable(Drawable)
Set the ActionBar's split background.
SetStackedBackgroundDrawable(Drawable)
Set the ActionBar's stacked background.
abstract
SetSubtitle(Int32)
Set the action bar's subtitle.
abstract
SetTitle(Int32)
Set the action bar's title.
abstract
Show()
Show the ActionBar if it is not currently showing.

Public Events