Share via


ActionBar Class

Definition

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

[Android.Runtime.Register("android/app/ActionBar", DoNotGenerateAcw=true)]
public abstract class ActionBar : Java.Lang.Object
[<Android.Runtime.Register("android/app/ActionBar", DoNotGenerateAcw=true)>]
type ActionBar = class
    inherit Object
Inheritance
ActionBar
Attributes

Remarks

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

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 android.R.style#Theme_Holo Holo theme (or one of its descendant themes), which is the default. You may otherwise add the action bar by calling android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR) or by declaring it in a custom theme with the android.R.styleable#Theme_windowActionBar 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 android.R.styleable#Theme_windowActionBar 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 #setLogo(int) logo in place of their standard title text.

From your activity, you can retrieve an instance of ActionBar by calling android.app.Activity#getActionBar getActionBar().

In some cases, the action bar may be overlayed by another bar that enables contextual actions, using an android.view.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 android.view.ActionMode APIs are distinct and independent from those for ActionBar.

<div class="special reference"> <h3>Developer Guides</h3>

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.

</div>

Java documentation for android.app.ActionBar.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

ActionBar()
ActionBar(IntPtr, JniHandleOwnership)

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

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
CustomView
DisplayOptions
Elevation

Get the Z-axis elevation of the action bar in pixels. -or- Set the Z-axis elevation of the action bar in pixels.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
Height

Retrieve the current height of the ActionBar.

HideOffset

Return the current vertical offset of the action bar. -or- Set the current hide offset of the action bar.

HideOnContentScrollEnabled

Return whether the action bar is configured to scroll out of sight along with a View#setNestedScrollingEnabled(boolean) nested scrolling child. -or- Enable hiding the action bar on content scroll.

IsShowing
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
NavigationItemCount

Get the number of navigation items present in the current navigation mode.

NavigationMode

Returns the current navigation mode.

PeerReference (Inherited from Object)
SelectedNavigationIndex

Get the position of the selected navigation item in list or tabbed navigation modes.

SelectedTab

Returns the currently selected tab if in tabbed navigation mode and there is at least one tab present.

Subtitle
SubtitleFormatted

Returns the current ActionBar subtitle in standard mode.

TabCount

Returns the number of tabs currently registered with the action bar.

ThemedContext

Returns a Context with an appropriate theme for creating views that will appear in the action bar.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Title
TitleFormatted

Returns the current ActionBar title in standard mode.

Methods

AddOnMenuVisibilityListener(ActionBar+IOnMenuVisibilityListener)

Add a listener that will respond to menu visibility change events.

AddTab(ActionBar+Tab, Boolean)
Obsolete.

Add a tab for use in tabbed navigation mode.

AddTab(ActionBar+Tab, Int32, Boolean)
Obsolete.

Add a tab for use in tabbed navigation mode.

AddTab(ActionBar+Tab, Int32)
Obsolete.

Add a tab for use in tabbed navigation mode.

AddTab(ActionBar+Tab)
Obsolete.

Add a tab for use in tabbed navigation mode.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetTabAt(Int32)
Obsolete.

Returns the tab at the specified index.

Hide()

Hide the ActionBar if it is currently showing.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
NewTab()
Obsolete.

Create and return a new ActionBar.Tab.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
RemoveAllTabs()
Obsolete.

Remove all tabs from the action bar and deselect the current tab.

RemoveOnMenuVisibilityListener(ActionBar+IOnMenuVisibilityListener)

Remove a menu visibility listener.

RemoveTab(ActionBar+Tab)
Obsolete.

Remove a tab from the action bar.

RemoveTabAt(Int32)
Obsolete.

Remove a tab from the action bar.

SelectTab(ActionBar+Tab)
Obsolete.

Select the specified tab.

SetBackgroundDrawable(Drawable)

Set the ActionBar's background.

SetCustomView(Int32)

Set the action bar into custom navigation mode, supplying a view for custom navigation.

SetCustomView(View, ActionBar+LayoutParams)

Set the action bar into custom navigation mode, supplying a view for custom navigation.

SetDisplayHomeAsUpEnabled(Boolean)

Set whether home should be displayed as an "up" affordance.

SetDisplayOptions(ActionBarDisplayOptions, ActionBarDisplayOptions)

Set selected display options.

SetDisplayShowCustomEnabled(Boolean)

Set whether a custom view should be displayed, if set.

SetDisplayShowHomeEnabled(Boolean)

Set whether to include the application home affordance in the action bar.

SetDisplayShowTitleEnabled(Boolean)

Set whether an activity title/subtitle should be displayed.

SetDisplayUseLogoEnabled(Boolean)

Set whether to display the activity logo rather than the activity icon.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
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)

Set an alternate description for the Home/Up action, when enabled.

SetHomeAsUpIndicator(Drawable)

Set an alternate drawable to display next to the icon/logo/title when #DISPLAY_HOME_AS_UP is enabled.

SetHomeAsUpIndicator(Int32)

Set an alternate drawable to display next to the icon/logo/title when #DISPLAY_HOME_AS_UP is enabled.

SetHomeButtonEnabled(Boolean)

Enable or disable the "home" button in the corner of the action bar.

SetIcon(Drawable)

Set the icon to display in the 'home' section of the action bar.

SetIcon(Int32)

Set the icon to display in the 'home' section of the action bar.

SetListNavigationCallbacks(ISpinnerAdapter, ActionBar+IOnNavigationListener)
Obsolete.

Set the adapter and navigation callback for list navigation mode.

SetLogo(Drawable)

Set the logo to display in the 'home' section of the action bar.

SetLogo(Int32)

Set the logo to display in the 'home' section of the action bar.

SetSelectedNavigationItem(Int32)
Obsolete.

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.

SetSubtitle(Int32)

Set the action bar's subtitle.

SetTitle(Int32)

Set the action bar's title.

Show()

Show the ActionBar if it is not currently showing.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Events

MenuVisibility

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to