Академический Документы
Профессиональный Документы
Культура Документы
java.lang.Object
↳ android.app.ActionBar
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.
Developer Guides
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.
Summary
Nested classes
ActionBar.LayoutParams
class
Per-child layout information associated with action bar custom views.
ActionBar.OnMenuVisibilityListener
interface
Listener for receiving events when action bar menus are shown or hidden.
ActionBar.OnNavigationListener
interface This interface was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using other
common navigation patterns instead.
ActionBar.Tab
class This class was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using other
common navigation patterns instead.
ActionBar.TabListener
interface This interface was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using other
common navigation patterns instead.
Constants
DISPLAY_HOME_AS_UP
int
Display the 'home' element such that it appears as an 'up' affordance.
DISPLAY_SHOW_CUSTOM
int
Show the custom view if one has been set.
DISPLAY_SHOW_HOME
int
Show 'home' elements in this action bar, leaving more space for other navigation elements.
DISPLAY_SHOW_TITLE
int
Show the activity title and subtitle, if present.
DISPLAY_USE_LOGO
int
Use logo instead of icon if available.
NAVIGATION_MODE_LIST
int This constant was deprecated in API level 21. Action bar navigation modes are deprecated
and not supported by inline toolbar action bars. Consider using other common navigation
patterns instead.
NAVIGATION_MODE_STANDARD
int This constant was deprecated in API level 21. Action bar navigation modes are deprecated
and not supported by inline toolbar action bars. Consider using other common navigation
patterns instead.
NAVIGATION_MODE_TABS
int This constant was deprecated in API level 21. Action bar navigation modes are deprecated
and not supported by inline toolbar action bars. Consider using other common navigation
patterns instead.
Public constructors
ActionBar()
Public methods
addOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener
listener)
abstract void
abstract void This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
addTab(ActionBar.Tab tab)
abstract void This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
addTab(ActionBar.Tab tab, int position, boolean setSelected)
abstract void This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
addTab(ActionBar.Tab tab, boolean setSelected)
abstract void This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
abstract View getCustomView()
abstract int getDisplayOptions()
getElevation()
float
Get the Z-axis elevation of the action bar in pixels.
getHeight()
abstract int
Retrieve the current height of the ActionBar.
getHideOffset()
int
Return the current vertical offset of the action bar.
getNavigationItemCount()
abstract int This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
getNavigationMode()
abstract int This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
getSelectedNavigationIndex()
abstract int This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
getSelectedTab()
abstract
ActionBar.Tab
This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
getSubtitle()
abstract
CharSequence
Returns the current ActionBar subtitle in standard mode.
getTabAt(int index)
abstract
ActionBar.Tab
This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
getTabCount()
abstract int This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
getThemedContext()
Context
Returns a Context with an appropriate theme for creating views that will
appear in the action bar.
abstract getTitle()
CharSequence
Returns the current ActionBar title in standard mode.
hide()
abstract void
Hide the ActionBar if it is currently showing.
isHideOnContentScrollEnabled()
boolean
Return whether the action bar is configured to scroll out of sight along with a
nested scrolling child.
abstract
isShowing()
boolean
newTab()
abstract
ActionBar.Tab
This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
removeAllTabs()
abstract void This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
removeOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListene
r listener)
abstract void
abstract void This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
removeTabAt(int position)
abstract void This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
selectTab(ActionBar.Tab tab)
abstract void This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
setBackgroundDrawable(Drawable d)
abstract void
Set the ActionBar's background.
setCustomView(View view, ActionBar.LayoutParams layoutParams)
abstract void
Set the action bar into custom navigation mode, supplying a view for custom
navigation.
setCustomView(View view)
abstract void
Set the action bar into custom navigation mode, supplying a view for custom
navigation.
setCustomView(int resId)
abstract void
Set the action bar into custom navigation mode, supplying a view for custom
navigation.
setDisplayHomeAsUpEnabled(boolean showHomeAsUp)
abstract void
Set whether home should be displayed as an "up" affordance.
setDisplayOptions(int options, int mask)
abstract void
Set selected display options.
setDisplayOptions(int options)
abstract void
Set display options.
setDisplayShowCustomEnabled(boolean showCustom)
abstract void
Set whether a custom view should be displayed, if set.
setDisplayShowHomeEnabled(boolean showHome)
abstract void
Set whether to include the application home affordance in the action bar.
setDisplayShowTitleEnabled(boolean showTitle)
abstract void
Set whether an activity title/subtitle should be displayed.
setDisplayUseLogoEnabled(boolean useLogo)
abstract void
Set whether to display the activity logo rather than the activity icon.
setElevation(float elevation)
void
Set the Z-axis elevation of the action bar in pixels.
setHideOffset(int offset)
void
Set the current hide offset of the action bar.
setHideOnContentScrollEnabled(boolean hideOnContentScroll)
void
Enable hiding the action bar on content scroll.
setHomeActionContentDescription(CharSequence description)
void
Set an alternate description for the Home/Up action, when enabled.
setHomeActionContentDescription(int resId)
void
Set an alternate description for the Home/Up action, when enabled.
void setHomeAsUpIndicator(int resId)
void
Set an alternate drawable to display next to the icon/logo/title when
DISPLAY_HOME_AS_UP is enabled.
setHomeButtonEnabled(boolean enabled)
void
Enable or disable the "home" button in the corner of the action bar.
setIcon(Drawable icon)
abstract void
Set the icon to display in the 'home' section of the action bar.
setIcon(int resId)
abstract void
Set the icon to display in the 'home' section of the action bar.
setListNavigationCallbacks(SpinnerAdapter adapter,
ActionBar.OnNavigationListener callback)
abstract void
This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
setLogo(int resId)
abstract void
Set the logo to display in the 'home' section of the action bar.
setLogo(Drawable logo)
abstract void
Set the logo to display in the 'home' section of the action bar.
setNavigationMode(int mode)
abstract void This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
setSelectedNavigationItem(int position)
abstract void This method was deprecated in API level 21. Action bar navigation modes are
deprecated and not supported by inline toolbar action bars. Consider using
other common navigation patterns instead.
setSplitBackgroundDrawable(Drawable d)
void
Set the ActionBar's split background.
setStackedBackgroundDrawable(Drawable d)
void
Set the ActionBar's stacked background.
setSubtitle(CharSequence subtitle)
abstract void
Set the action bar's subtitle.
abstract void setSubtitle(int resId)
Set the action bar's subtitle.
setTitle(CharSequence title)
abstract void
Set the action bar's title.
setTitle(int resId)
abstract void
Set the action bar's title.
show()
abstract void
Show the ActionBar if it is not currently showing.
Inherited methods
Constants
DISPLAY_HOME_AS_UP
Display the 'home' element such that it appears as an 'up' affordance. e.g. show an arrow to the
left indicating the action that will be taken. Set this flag if selecting the 'home' button in the
action bar to return up by a single level in your UI rather than back to the top level or front page.
Setting this option will implicitly enable interaction with the home/up button. See
setHomeButtonEnabled(boolean).
See also:
setDisplayOptions(int)
setDisplayOptions(int, int)
DISPLAY_SHOW_CUSTOM
setCustomView(View)
setDisplayOptions(int)
setDisplayOptions(int, int)
DISPLAY_SHOW_HOME
Show 'home' elements in this action bar, leaving more space for other navigation elements. This
includes logo and icon.
See also:
setDisplayOptions(int)
setDisplayOptions(int, int)
DISPLAY_SHOW_TITLE
See also:
setTitle(CharSequence)
setTitle(int)
setSubtitle(CharSequence)
setSubtitle(int)
setDisplayOptions(int)
setDisplayOptions(int, int)
DISPLAY_USE_LOGO
See also:
setDisplayOptions(int)
setDisplayOptions(int, int)
NAVIGATION_MODE_LIST
List navigation mode. Instead of static title text this mode presents a list menu for navigation
within the activity. e.g. this might be presented to the user as a dropdown list.
NAVIGATION_MODE_STANDARD
Standard navigation mode. Consists of either a logo or icon and title text with an optional
subtitle. Clicking any of these elements will dispatch onOptionsItemSelected to the host Activity
with a MenuItem with item ID android.R.id.home.
NAVIGATION_MODE_TABS
Tab navigation mode. Instead of static title text this mode presents a series of tabs for navigation
within the activity.
Public constructors
ActionBar
Public methods
addOnMenuVisibilityListener
Parameters
listener ActionBar.OnMenuVisibilityListener: The new listener to add
addTab
Add a tab for use in tabbed navigation mode. The tab will be inserted at position. If this is the
first tab to be added it will become the selected tab.
Parameters
tab ActionBar.Tab: The tab to add
position int: The new position of the tab
addTab
Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. If this is
the first tab to be added it will become the selected tab.
Parameters
tab ActionBar.Tab: Tab to add
addTab
Add a tab for use in tabbed navigation mode. The tab will be insterted at position.
Parameters
tab ActionBar.Tab: The tab to add
position int: The new position of the tab
setSelected boolean: True if the added tab should become the selected tab.
addTab
Parameters
tab ActionBar.Tab: Tab to add
setSelected boolean: True if the added tab should become the selected tab.
getCustomView
getDisplayOptions
getElevation
The action bar's elevation is the distance it is placed from its parent surface. Higher values are
closer to the user.
Returns
float Elevation value in pixels
getHeight
Returns
int The ActionBar's height
getHideOffset
added in API level 21
int getHideOffset ()
The action bar's current hide offset is the distance that the action bar is currently scrolled
offscreen in pixels. The valid range is 0 (fully visible) to the action bar's current measured
height (fully invisible).
Returns
int The action bar's offset toward its fully hidden state in pixels
getNavigationItemCount
Get the number of navigation items present in the current navigation mode.
Returns
int Number of navigation items.
getNavigationMode
Returns the current navigation mode. The result will be one of:
NAVIGATION_MODE_STANDARD
NAVIGATION_MODE_LIST
NAVIGATION_MODE_TABS
Returns
int The current navigation mode.
getSelectedNavigationIndex
added in API level 11
int getSelectedNavigationIndex ()
Get the position of the selected navigation item in list or tabbed navigation modes.
Returns
int Position of the selected item.
getSelectedTab
Returns the currently selected tab if in tabbed navigation mode and there is at least one tab
present.
Returns
ActionBar.Tab The currently selected tab or null
getSubtitle
Returns the current ActionBar subtitle in standard mode. Returns null if getNavigationMode()
would not return NAVIGATION_MODE_STANDARD.
Returns
CharSequence The current ActionBar subtitle or null.
getTabAt
Parameters
index int: Index value in the range 0-get
Returns
ActionBar.Tab
getTabCount
Returns the number of tabs currently registered with the action bar.
Returns
int Tab count
getThemedContext
Returns a Context with an appropriate theme for creating views that will appear in the action
bar. If you are inflating or instantiating custom views that will appear in an action bar, you
should use the Context returned by this method. (This includes adapters used for list navigation
mode.) This will ensure that views contrast properly against the action bar.
Returns
Context A themed Context for creating views
getTitle
Returns the current ActionBar title in standard mode. Returns null if getNavigationMode()
would not return NAVIGATION_MODE_STANDARD.
Returns
CharSequence The current ActionBar title or null.
hide
Hide the ActionBar if it is currently showing. If the window hosting the ActionBar does not have
the feature FEATURE_ACTION_BAR_OVERLAY it will resize application content to fit the new space
available.
Instead of calling this function directly, you can also cause an ActionBar using the overlay
feature to hide through View.SYSTEM_UI_FLAG_FULLSCREEN. Hiding the ActionBar through this
system UI flag allows you to more seamlessly hide it in conjunction with other screen
decorations.
isHideOnContentScrollEnabled
Return whether the action bar is configured to scroll out of sight along with a nested
scrolling child.
Returns
boolean true if hide-on-content-scroll is enabled
See also:
setHideOnContentScrollEnabled(boolean)
isShowing
newTab
Very often tabs will be used to switch between Fragment objects. Here is a typical
implementation of such tabs:
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.widget.Toast;
/**
* This demonstrates the use of action bar tabs and how they interact
* with other action bar features.
*/
public class FragmentTabs extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bar.addTab(bar.newTab()
.setText("Simple")
.setTabListener(new
TabListener<FragmentStack.CountingFragment>(
this, "simple",
FragmentStack.CountingFragment.class)));
bar.addTab(bar.newTab()
.setText("Contacts")
.setTabListener(new
TabListener<LoaderCursor.CursorLoaderListFragment>(
this, "contacts",
LoaderCursor.CursorLoaderListFragment.class)));
bar.addTab(bar.newTab()
.setText("Apps")
.setTabListener(new TabListener<LoaderCustom.AppListFragment>(
this, "apps", LoaderCustom.AppListFragment.class)));
bar.addTab(bar.newTab()
.setText("Throttle")
.setTabListener(new
TabListener<LoaderThrottle.ThrottledLoaderListFragment>(
this, "throttle",
LoaderThrottle.ThrottledLoaderListFragment.class)));
if (savedInstanceState != null) {
bar.setSelectedNavigationItem(savedInstanceState.getInt("tab",
0));
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("tab", getActionBar().getSelectedNavigationIndex());
}
See also:
addTab(Tab)
removeAllTabs
Remove all tabs from the action bar and deselect the current tab.
removeOnMenuVisibilityListener
Remove a menu visibility listener. This listener will no longer receive menu visibility change
events.
Parameters
ActionBar.OnMenuVisibilityListener: A listener to remove that was previously
listener
added
removeTab
Parameters
tab ActionBar.Tab: The tab to remove
removeTabAt
Remove a tab from the action bar. If the removed tab was selected it will be deselected and
another tab will be selected if present.
Parameters
position int: Position of the tab to remove
selectTab
Select the specified tab. If it is not a child of this action bar it will be added.
Parameters
tab ActionBar.Tab: Tab to select
setBackgroundDrawable
Set the ActionBar's background. This will be used for the primary action bar.
Parameters
Drawable: Background drawable
d
This value may be null.
See also:
setStackedBackgroundDrawable(Drawable)
setSplitBackgroundDrawable(Drawable)
setCustomView
Set the action bar into custom navigation mode, supplying a view for custom navigation.
Custom navigation views appear between the application icon and any action buttons and may
use any space available there. Common use cases for custom navigation views might include an
auto-suggesting address bar for a browser or other navigation mechanisms that do not translate
well to provided navigation modes.
The display option DISPLAY_SHOW_CUSTOM must be set for the custom view to be displayed.
Parameters
view View: Custom navigation view to place in the ActionBar.
layoutParams ActionBar.LayoutParams: How this custom view should layout in the bar.
See also:
setDisplayOptions(int, int)
setCustomView
Set the action bar into custom navigation mode, supplying a view for custom navigation. Custom
navigation views appear between the application icon and any action buttons and may use any
space available there. Common use cases for custom navigation views might include an auto-
suggesting address bar for a browser or other navigation mechanisms that do not translate well to
provided navigation modes.
Parameters
view View: Custom navigation view to place in the ActionBar.
setCustomView
Set the action bar into custom navigation mode, supplying a view for custom navigation.
Custom navigation views appear between the application icon and any action buttons and may
use any space available there. Common use cases for custom navigation views might include an
auto-suggesting address bar for a browser or other navigation mechanisms that do not translate
well to provided navigation modes.
The display option DISPLAY_SHOW_CUSTOM must be set for the custom view to be displayed.
Parameters
resId int: Resource ID of a layout to inflate into the ActionBar.
See also:
setDisplayOptions(int, int)
setDisplayHomeAsUpEnabled
Set whether home should be displayed as an "up" affordance. Set this to true if selecting "home"
returns up by a single level in your UI rather than back to the top level or front page.
Parameters
boolean: true to show the user that selecting home will return one level up rather
showHomeAsUp
than to the top level of the app.
See also:
setDisplayOptions(int)
setDisplayOptions(int, int)
setDisplayOptions
Parameters
int:
A combination of the bits defined by the DISPLAY_ constants defined in
options
ActionBar.
mask int: A bit mask declaring which display options should be changed.
setDisplayOptions
Set display options. This changes all display option bits at once. To change a limited subset of
display options, see setDisplayOptions(int, int).
Parameters
int: A combination of the bits defined by the DISPLAY_ constants defined in
options
ActionBar.
setDisplayShowCustomEnabled
Parameters
showCustom boolean: true if the currently set custom view should be displayed, false otherwise.
See also:
setDisplayOptions(int)
setDisplayOptions(int, int)
setDisplayShowHomeEnabled
Set whether to include the application home affordance in the action bar. Home is presented as
either an activity icon or logo.
Parameters
showHome boolean: true to show home, false otherwise.
See also:
setDisplayOptions(int)
setDisplayOptions(int, int)
setDisplayShowTitleEnabled
Parameters
showTitle boolean: true to display a title/subtitle if present.
See also:
setDisplayOptions(int)
setDisplayOptions(int, int)
setDisplayUseLogoEnabled
Set whether to display the activity logo rather than the activity icon. A logo is often a wider,
more detailed image.
Parameters
useLogo boolean: true to use the activity logo, false to use the activity icon.
See also:
setDisplayOptions(int)
setDisplayOptions(int, int)
setElevation
The action bar's elevation is the distance it is placed from its parent surface. Higher values are
closer to the user.
Parameters
elevation float: Elevation value in pixels
setHideOffset
The action bar's current hide offset is the distance that the action bar is currently scrolled
offscreen in pixels. The valid range is 0 (fully visible) to the action bar's current measured
height (fully invisible).
Parameters
offset int: The action bar's offset toward its fully hidden state in pixels.
setHideOnContentScrollEnabled
If enabled, the action bar will scroll out of sight along with a nested scrolling child view's
content. The action bar must be in overlay mode to enable hiding on content scroll.
When partially scrolled off screen the action bar is considered hidden. A call to show will cause
it to return to full view.
Parameters
hideOnContentScroll boolean: true to enable hiding on content scroll.
setHomeActionContentDescription
This description is commonly used for accessibility/screen readers when the Home action is
enabled. (See setDisplayHomeAsUpEnabled(boolean).) Examples of this are, "Navigate
Home" or "Navigate Up" depending on the DISPLAY_HOME_AS_UP display option. If you have
changed the home-as-up indicator using setHomeAsUpIndicator(int) to indicate more specific
functionality such as a sliding drawer, you should also set this to accurately describe the action.
Parameters
description CharSequence: New description for the Home action when enabled
See also:
setHomeAsUpIndicator(int)
setHomeAsUpIndicator(android.graphics.drawable.Drawable)
setHomeActionContentDescription
This description is commonly used for accessibility/screen readers when the Home action is
enabled. (See setDisplayHomeAsUpEnabled(boolean).) Examples of this are, "Navigate
Home" or "Navigate Up" depending on the DISPLAY_HOME_AS_UP display option. If you have
changed the home-as-up indicator using setHomeAsUpIndicator(int) to indicate more specific
functionality such as a sliding drawer, you should also set this to accurately describe the action.
Parameters
int: Resource ID of a string to use as the new description for the Home action when
resId
enabled
See also:
setHomeAsUpIndicator(int)
setHomeAsUpIndicator(android.graphics.drawable.Drawable)
setHomeAsUpIndicator
If you pass 0 to this method, the default drawable from the theme will be used.
If you implement alternate or intermediate behavior around Up, you should also call
setHomeActionContentDescription() to provide a correct description of the action for
accessibility support.
Parameters
int: Resource ID of a drawable to use for the up indicator, or null to use the theme's
resId
default
See also:
setDisplayOptions(int, int)
setDisplayHomeAsUpEnabled(boolean)
setHomeActionContentDescription(int)
setHomeAsUpIndicator
If you pass null to this method, the default drawable from the theme will be used.
If you implement alternate or intermediate behavior around Up, you should also call
setHomeActionContentDescription() to provide a correct description of the action for
accessibility support.
Parameters
indicator Drawable: A drawable to use for the up indicator, or null to use the theme's default
See also:
setDisplayOptions(int, int)
setDisplayHomeAsUpEnabled(boolean)
setHomeActionContentDescription(int)
setHomeButtonEnabled
Enable or disable the "home" button in the corner of the action bar. (Note that this is the
application home/up affordance on the action bar, not the systemwide home button.)
This defaults to true for packages targeting < API 14. For packages targeting API 14 or greater,
the application should call this method to enable interaction with the home/up affordance.
Setting the DISPLAY_HOME_AS_UP display option will automatically enable the home button.
Parameters
enabled boolean: true to enable the home button, false to disable the home button.
setIcon
Set the icon to display in the 'home' section of the action bar. The action bar will use an icon
specified by its style or the activity icon by default. Whether the home section shows an icon or
logo is controlled by the display option DISPLAY_USE_LOGO.
Parameters
icon Drawable: Drawable to show as an icon.
See also:
setDisplayUseLogoEnabled(boolean)
setDisplayShowHomeEnabled(boolean)
setIcon
Set the icon to display in the 'home' section of the action bar. The action bar will use an icon
specified by its style or the activity icon by default. Whether the home section shows an icon or
logo is controlled by the display option DISPLAY_USE_LOGO.
Parameters
resId int: Resource ID of a drawable to show as an icon.
See also:
setDisplayUseLogoEnabled(boolean)
setDisplayShowHomeEnabled(boolean)
setListNavigationCallbacks
Set the adapter and navigation callback for list navigation mode. The supplied adapter will
provide views for the expanded list as well as the currently selected item. (These may be
displayed differently.) The supplied OnNavigationListener will alert the application when the
user changes the current list selection.
Parameters
SpinnerAdapter: An adapter that will provide views both to display the current
adapter
navigation selection and populate views within the dropdown navigation menu.
ActionBar.OnNavigationListener: An OnNavigationListener that will receive
callback
events when the user selects a navigation item.
setLogo
Set the logo to display in the 'home' section of the action bar. The action bar will use a logo
specified by its style or the activity logo by default. Whether the home section shows an icon or
logo is controlled by the display option DISPLAY_USE_LOGO.
Parameters
resId int: Resource ID of a drawable to show as a logo.
See also:
setDisplayUseLogoEnabled(boolean)
setDisplayShowHomeEnabled(boolean)
setLogo
Set the logo to display in the 'home' section of the action bar. The action bar will use a logo
specified by its style or the activity logo by default. Whether the home section shows an icon or
logo is controlled by the display option DISPLAY_USE_LOGO.
Parameters
logo Drawable: Drawable to show as a logo.
See also:
setDisplayUseLogoEnabled(boolean)
setDisplayShowHomeEnabled(boolean)
setNavigationMode
Parameters
mode int: The new mode to set.
See also:
NAVIGATION_MODE_STANDARD
NAVIGATION_MODE_LIST
NAVIGATION_MODE_TABS
setSelectedNavigationItem
Parameters
position int: Position of the item to select.
setSplitBackgroundDrawable
Set the ActionBar's split background. This will appear in the split action bar containing menu-
provided action buttons on some devices and configurations.
Parameters
d Drawable: Background drawable for the split bar
setStackedBackgroundDrawable
Set the ActionBar's stacked background. This will appear in the second row/stacked bar on some
devices and configurations.
Parameters
d Drawable: Background drawable for the stacked row
setSubtitle
Set the action bar's subtitle. This will only be displayed if DISPLAY_SHOW_TITLE is set. Set to
null to disable the subtitle entirely.
Parameters
subtitle CharSequence: Subtitle to set
See also:
setSubtitle(int)
setDisplayOptions(int, int)
setSubtitle
Set the action bar's subtitle. This will only be displayed if DISPLAY_SHOW_TITLE is set.
Parameters
resId int: Resource ID of subtitle string to set
See also:
setSubtitle(CharSequence)
setDisplayOptions(int, int)
setTitle
Set the action bar's title. This will only be displayed if DISPLAY_SHOW_TITLE is set.
Parameters
title CharSequence: Title to set
See also:
setTitle(int)
setDisplayOptions(int, int)
setTitle
Set the action bar's title. This will only be displayed if DISPLAY_SHOW_TITLE is set.
Parameters
resId int: Resource ID of title string to set
See also:
setTitle(CharSequence)
setDisplayOptions(int, int)
show
Show the ActionBar if it is not currently showing. If the window hosting the ActionBar does not
have the feature FEATURE_ACTION_BAR_OVERLAY it will resize application content to fit the new
space available.
If you are hiding the ActionBar through View.SYSTEM_UI_FLAG_FULLSCREEN, you should not
call this function directly.