ActionBar Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
- 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 Holo theme (or one of its descendant themes), which is the default. You may otherwise add the action bar by calling requestFeature(FEATURE_ACTION_BAR) or by declaring it in a custom theme with the 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 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 logo in place of their standard title text.
From your activity, you can retrieve an instance of ActionBar by calling getActionBar().
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 reference 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
| Name | Description |
|---|---|
| ActionBar() | |
| ActionBar(IntPtr, JniHandleOwnership) |
Initializes a managed representation of an existing Java Native Interface object. |
Properties
| Name | Description |
|---|---|
| Class |
Returns the runtime class of this |
| CustomView | |
| DisplayOptions | |
| Elevation |
Get 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. |
| HideOnContentScrollEnabled |
Return whether the action bar is configured to scroll out of sight along with a nested scrolling child. |
| IsShowing | |
| JniIdentityHashCode |
Gets the identity hash code assigned to this Java peer by the interop runtime. (Inherited from Object) |
| JniManagedPeerState | (Inherited from JavaObject) |
| JniPeerMembers |
Provides JNI binding infrastructure for Android.App.ActionBar. |
| NavigationItemCount |
This method was deprecated in API level 21. |
| NavigationMode |
This method was deprecated in API level 21. |
| PeerReference |
Gets the JNI object reference for this Java peer. (Inherited from Object) |
| SelectedNavigationIndex |
This method was deprecated in API level 21. |
| SelectedTab |
This method was deprecated in API level 21. |
| Subtitle | |
| SubtitleFormatted |
Returns the current ActionBar subtitle in standard mode. |
| TabCount |
This method was deprecated in API level 21. |
| ThemedContext |
Returns a Context with an appropriate theme for creating views that will appear in the action bar. |
| ThresholdClass |
Provides JNI binding infrastructure for Android.App.ActionBar. |
| ThresholdType |
Provides JNI binding infrastructure for Android.App.ActionBar. |
| Title | |
| TitleFormatted |
Returns the current ActionBar title in standard mode. |
Methods
| Name | Description |
|---|---|
| AddOnMenuVisibilityListener(ActionBar+IOnMenuVisibilityListener) |
Add a listener that will respond to menu visibility change events. |
| AddTab(ActionBar+Tab, Boolean) |
Obsolete.
This method was deprecated in API level 21. |
| AddTab(ActionBar+Tab, Int32, Boolean) |
Obsolete.
This method was deprecated in API level 21. |
| AddTab(ActionBar+Tab, Int32) |
Obsolete.
This method was deprecated in API level 21. |
| AddTab(ActionBar+Tab) |
Obsolete.
This method was deprecated in API level 21. |
| Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
| Construct(JniObjectReference, JniObjectReferenceOptions) | (Inherited from JavaObject) |
| Dispose() |
Releases the resources held by this Java peer. (Inherited from Object) |
| Dispose(Boolean) |
Releases the resources held by this Java peer. (Inherited from Object) |
| DisposeUnlessReferenced() | (Inherited from JavaObject) |
| Equals(Object) | (Inherited from JavaObject) |
| 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.
This method was deprecated in API level 21. |
| 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.
This method was deprecated in API level 21. |
| 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.
This method was deprecated in API level 21. |
| RemoveOnMenuVisibilityListener(ActionBar+IOnMenuVisibilityListener) |
Remove a menu visibility listener. |
| RemoveTab(ActionBar+Tab) |
Obsolete.
This method was deprecated in API level 21. |
| RemoveTabAt(Int32) |
Obsolete.
This method was deprecated in API level 21. |
| SelectTab(ActionBar+Tab) |
Obsolete.
This method was deprecated in API level 21. |
| 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.
This method was deprecated in API level 21. |
| 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. |
| SetPeerReference(JniObjectReference, JniObjectReferenceOptions) | (Inherited from JavaObject) |
| SetSelectedNavigationItem(Int32) |
Obsolete.
This method was deprecated in API level 21. |
| 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>() |
Creates a managed array from this Java array wrapper. (Inherited from Object) |
| ToString() |
Returns a string representation of the object. (Inherited from Object) |
| UnregisterFromRuntime() |
Unregisters this Java peer from the interop runtime. (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
| Name | Description |
|---|---|
| MenuVisibility | |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IJavaPeerable.Disposed() | (Inherited from JavaObject) |
| IJavaPeerable.Finalized() | (Inherited from JavaObject) |
| IJavaPeerable.JniObjectReferenceControlBlock | (Inherited from JavaObject) |
| IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from JavaObject) |
| IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from JavaObject) |
| IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from JavaObject) |
Extension Methods
| Name | Description |
|---|---|
| GetJniTypeName(IJavaPeerable) |
Gets the JNI name of the type of the instance |
| JavaAs<TResult>(IJavaPeerable) |
Try to coerce |
| JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
| JavaCast<TResult>(IJavaObject) | |
| TryJavaCast<TResult>(IJavaPeerable, TResult) |
Try to coerce |