public class ActionBarImpl extends ActionBar
Modifier and Type | Class and Description |
---|---|
class |
ActionBarImpl.ActionModeImpl |
class |
ActionBarImpl.TabImpl |
ActionBar.LayoutParams, ActionBar.OnMenuVisibilityListener, ActionBar.OnNavigationListener, ActionBar.Tab, ActionBar.TabListener
DISPLAY_HOME_AS_UP, DISPLAY_SHOW_CUSTOM, DISPLAY_SHOW_HOME, DISPLAY_SHOW_TITLE, DISPLAY_USE_LOGO, NAVIGATION_MODE_LIST, NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_TABS
Constructor and Description |
---|
ActionBarImpl(android.app.Activity activity,
int features) |
ActionBarImpl(android.app.Dialog dialog) |
Modifier and Type | Method and Description |
---|---|
void |
addOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener)
Add a listener that will respond to menu visibility change events.
|
void |
addTab(ActionBar.Tab tab)
Add a tab for use in tabbed navigation mode.
|
void |
addTab(ActionBar.Tab tab,
boolean setSelected)
Add a tab for use in tabbed navigation mode.
|
void |
addTab(ActionBar.Tab tab,
int position)
Add a tab for use in tabbed navigation mode.
|
void |
addTab(ActionBar.Tab tab,
int position,
boolean setSelected)
Add a tab for use in tabbed navigation mode.
|
void |
dispatchMenuVisibilityChanged(boolean isVisible) |
android.view.View |
getCustomView() |
int |
getDisplayOptions() |
int |
getHeight()
Retrieve the current height of the ActionBar.
|
int |
getNavigationItemCount()
Get the number of navigation items present in the current navigation mode.
|
int |
getNavigationMode()
Returns the current navigation mode.
|
int |
getSelectedNavigationIndex()
Get the position of the selected navigation item in list or tabbed navigation modes.
|
ActionBar.Tab |
getSelectedTab()
Returns the currently selected tab if in tabbed navigation mode and there is at least
one tab present.
|
CharSequence |
getSubtitle()
Returns the current ActionBar subtitle in standard mode.
|
ActionBar.Tab |
getTabAt(int index)
Returns the tab at the specified index.
|
int |
getTabCount()
Returns the number of tabs currently registered with the action bar.
|
android.content.Context |
getThemedContext()
Returns a
Context with an appropriate theme for creating views that
will appear in the action bar. |
CharSequence |
getTitle()
Returns the current ActionBar title in standard mode.
|
void |
hide()
Hide the ActionBar if it is currently showing.
|
boolean |
isShowing() |
ActionBar.Tab |
newTab()
Create and return a new
ActionBar.Tab . |
void |
onConfigurationChanged(android.content.res.Configuration newConfig) |
void |
removeAllTabs()
Remove all tabs from the action bar and deselect the current tab.
|
void |
removeOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener)
Remove a menu visibility listener.
|
void |
removeTab(ActionBar.Tab tab)
Remove a tab from the action bar.
|
void |
removeTabAt(int position)
Remove a tab from the action bar.
|
void |
selectTab(ActionBar.Tab tab)
Select the specified tab.
|
void |
setBackgroundDrawable(android.graphics.drawable.Drawable d)
Set the ActionBar's background.
|
void |
setCustomView(int resId)
Set the action bar into custom navigation mode, supplying a view
for custom navigation.
|
void |
setCustomView(android.view.View view)
Set the action bar into custom navigation mode, supplying a view
for custom navigation.
|
void |
setCustomView(android.view.View view,
ActionBar.LayoutParams layoutParams)
Set the action bar into custom navigation mode, supplying a view
for custom navigation.
|
void |
setDisplayHomeAsUpEnabled(boolean showHomeAsUp)
Set whether home should be displayed as an "up" affordance.
|
void |
setDisplayOptions(int options)
Set display options.
|
void |
setDisplayOptions(int options,
int mask)
Set selected display options.
|
void |
setDisplayShowCustomEnabled(boolean showCustom)
Set whether a custom view should be displayed, if set.
|
void |
setDisplayShowHomeEnabled(boolean showHome)
Set whether to include the application home affordance in the action bar.
|
void |
setDisplayShowTitleEnabled(boolean showTitle)
Set whether an activity title/subtitle should be displayed.
|
void |
setDisplayUseLogoEnabled(boolean useLogo)
Set whether to display the activity logo rather than the activity icon.
|
void |
setHomeButtonEnabled(boolean enable)
Enable or disable the "home" button in the corner of the action bar.
|
void |
setIcon(android.graphics.drawable.Drawable icon)
Set the icon to display in the 'home' section of the action bar.
|
void |
setIcon(int resId)
Set the icon to display in the 'home' section of the action bar.
|
void |
setListNavigationCallbacks(android.widget.SpinnerAdapter adapter,
ActionBar.OnNavigationListener callback)
Set the adapter and navigation callback for list navigation mode.
|
void |
setLogo(android.graphics.drawable.Drawable logo)
Set the logo to display in the 'home' section of the action bar.
|
void |
setLogo(int resId)
Set the logo to display in the 'home' section of the action bar.
|
void |
setNavigationMode(int mode)
Set the current navigation mode.
|
void |
setSelectedNavigationItem(int position)
Set the selected navigation item in list or tabbed navigation modes.
|
void |
setShowHideAnimationEnabled(boolean enabled)
Enables or disables animation between show/hide states.
|
void |
setSplitBackgroundDrawable(android.graphics.drawable.Drawable d)
Set the ActionBar's split background.
|
void |
setStackedBackgroundDrawable(android.graphics.drawable.Drawable d)
Set the ActionBar's stacked background.
|
void |
setSubtitle(CharSequence subtitle)
Set the action bar's subtitle.
|
void |
setSubtitle(int resId)
Set the action bar's subtitle.
|
void |
setTitle(CharSequence title)
Set the action bar's title.
|
void |
setTitle(int resId)
Set the action bar's title.
|
void |
show()
Show the ActionBar if it is not currently showing.
|
ActionMode |
startActionMode(ActionMode.Callback callback) |
public ActionBarImpl(android.app.Activity activity, int features)
public ActionBarImpl(android.app.Dialog dialog)
public void onConfigurationChanged(android.content.res.Configuration newConfig)
public void setShowHideAnimationEnabled(boolean enabled)
enabled
- true to animate, false to not animate.public void addOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener)
ActionBar
addOnMenuVisibilityListener
in class ActionBar
listener
- The new listener to addpublic void removeOnMenuVisibilityListener(ActionBar.OnMenuVisibilityListener listener)
ActionBar
removeOnMenuVisibilityListener
in class ActionBar
listener
- A listener to remove that was previously addedpublic void dispatchMenuVisibilityChanged(boolean isVisible)
public void setCustomView(int resId)
ActionBar
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 ActionBar.DISPLAY_SHOW_CUSTOM
must be set for
the custom view to be displayed.
setCustomView
in class ActionBar
resId
- Resource ID of a layout to inflate into the ActionBar.ActionBar.setDisplayOptions(int, int)
public void setDisplayUseLogoEnabled(boolean useLogo)
ActionBar
To set several display options at once, see the setDisplayOptions methods.
setDisplayUseLogoEnabled
in class ActionBar
useLogo
- true to use the activity logo, false to use the activity icon.ActionBar.setDisplayOptions(int)
,
ActionBar.setDisplayOptions(int, int)
public void setDisplayShowHomeEnabled(boolean showHome)
ActionBar
To set several display options at once, see the setDisplayOptions methods.
setDisplayShowHomeEnabled
in class ActionBar
showHome
- true to show home, false otherwise.ActionBar.setDisplayOptions(int)
,
ActionBar.setDisplayOptions(int, int)
public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp)
ActionBar
To set several display options at once, see the setDisplayOptions methods.
setDisplayHomeAsUpEnabled
in class ActionBar
showHomeAsUp
- true to show the user that selecting home will return one
level up rather than to the top level of the app.ActionBar.setDisplayOptions(int)
,
ActionBar.setDisplayOptions(int, int)
public void setDisplayShowTitleEnabled(boolean showTitle)
ActionBar
To set several display options at once, see the setDisplayOptions methods.
setDisplayShowTitleEnabled
in class ActionBar
showTitle
- true to display a title/subtitle if present.ActionBar.setDisplayOptions(int)
,
ActionBar.setDisplayOptions(int, int)
public void setDisplayShowCustomEnabled(boolean showCustom)
ActionBar
To set several display options at once, see the setDisplayOptions methods.
setDisplayShowCustomEnabled
in class ActionBar
showCustom
- true if the currently set custom view should be displayed, false otherwise.ActionBar.setDisplayOptions(int)
,
ActionBar.setDisplayOptions(int, int)
public void setHomeButtonEnabled(boolean enable)
ActionBar
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 ActionBar.DISPLAY_HOME_AS_UP
display option will automatically enable
the home button.
setHomeButtonEnabled
in class ActionBar
enable
- true to enable the home button, false to disable the home button.public void setTitle(int resId)
ActionBar
ActionBar.DISPLAY_SHOW_TITLE
is set.setTitle
in class ActionBar
resId
- Resource ID of title string to setActionBar.setTitle(CharSequence)
,
ActionBar.setDisplayOptions(int, int)
public void setSubtitle(int resId)
ActionBar
ActionBar.DISPLAY_SHOW_TITLE
is set.setSubtitle
in class ActionBar
resId
- Resource ID of subtitle string to setActionBar.setSubtitle(CharSequence)
,
ActionBar.setDisplayOptions(int, int)
public void setSelectedNavigationItem(int position)
ActionBar
setSelectedNavigationItem
in class ActionBar
position
- Position of the item to select.public void removeAllTabs()
ActionBar
removeAllTabs
in class ActionBar
public void setTitle(CharSequence title)
ActionBar
ActionBar.DISPLAY_SHOW_TITLE
is set.setTitle
in class ActionBar
title
- Title to setActionBar.setTitle(int)
,
ActionBar.setDisplayOptions(int, int)
public void setSubtitle(CharSequence subtitle)
ActionBar
ActionBar.DISPLAY_SHOW_TITLE
is set. Set to null to disable the
subtitle entirely.setSubtitle
in class ActionBar
subtitle
- Subtitle to setActionBar.setSubtitle(int)
,
ActionBar.setDisplayOptions(int, int)
public void setDisplayOptions(int options)
ActionBar
ActionBar.setDisplayOptions(int, int)
.setDisplayOptions
in class ActionBar
options
- A combination of the bits defined by the DISPLAY_ constants
defined in ActionBar.public void setDisplayOptions(int options, int mask)
ActionBar
ActionBar.setDisplayOptions(int)
.
Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the
ActionBar.DISPLAY_SHOW_HOME
option.
setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO)
will enable ActionBar.DISPLAY_SHOW_HOME
and disable ActionBar.DISPLAY_USE_LOGO
.
setDisplayOptions
in class ActionBar
options
- A combination of the bits defined by the DISPLAY_ constants
defined in ActionBar.mask
- A bit mask declaring which display options should be changed.public void setBackgroundDrawable(android.graphics.drawable.Drawable d)
ActionBar
setBackgroundDrawable
in class ActionBar
d
- Background drawableActionBar.setStackedBackgroundDrawable(Drawable)
,
ActionBar.setSplitBackgroundDrawable(Drawable)
public void setStackedBackgroundDrawable(android.graphics.drawable.Drawable d)
ActionBar
setStackedBackgroundDrawable
in class ActionBar
d
- Background drawable for the stacked rowpublic void setSplitBackgroundDrawable(android.graphics.drawable.Drawable d)
ActionBar
You can enable split action bar with R.attr.uiOptions
setSplitBackgroundDrawable
in class ActionBar
d
- Background drawable for the split barpublic android.view.View getCustomView()
getCustomView
in class ActionBar
public CharSequence getTitle()
ActionBar
ActionBar.getNavigationMode()
would not return
ActionBar.NAVIGATION_MODE_STANDARD
.public CharSequence getSubtitle()
ActionBar
ActionBar.getNavigationMode()
would not return
ActionBar.NAVIGATION_MODE_STANDARD
.getSubtitle
in class ActionBar
public int getNavigationMode()
ActionBar
getNavigationMode
in class ActionBar
public int getDisplayOptions()
getDisplayOptions
in class ActionBar
public ActionMode startActionMode(ActionMode.Callback callback)
public void addTab(ActionBar.Tab tab)
ActionBar
public void addTab(ActionBar.Tab tab, int position)
ActionBar
position
. If this is the first tab to be added it will become
the selected tab.public void addTab(ActionBar.Tab tab, boolean setSelected)
ActionBar
public void addTab(ActionBar.Tab tab, int position, boolean setSelected)
ActionBar
position
.public ActionBar.Tab newTab()
ActionBar
ActionBar.Tab
.
This tab will not be included in the action bar until it is added.
Very often tabs will be used to switch between Fragment
objects. Here is a typical implementation of such tabs:
newTab
in class ActionBar
ActionBar.addTab(Tab)
public void removeTab(ActionBar.Tab tab)
ActionBar
public void removeTabAt(int position)
ActionBar
removeTabAt
in class ActionBar
position
- Position of the tab to removepublic void selectTab(ActionBar.Tab tab)
ActionBar
Note: If you want to select by index, use ActionBar.setSelectedNavigationItem(int)
.
public ActionBar.Tab getSelectedTab()
ActionBar
getSelectedTab
in class ActionBar
public int getHeight()
ActionBar
public void show()
ActionBar
Window#FEATURE_ACTION_BAR_OVERLAY
it will resize application
content to fit the new space available.public void hide()
ActionBar
Window#FEATURE_ACTION_BAR_OVERLAY
it will resize application
content to fit the new space available.public boolean isShowing()
public android.content.Context getThemedContext()
ActionBar
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.getThemedContext
in class ActionBar
public void setCustomView(android.view.View view)
ActionBar
setCustomView
in class ActionBar
view
- Custom navigation view to place in the ActionBar.public void setCustomView(android.view.View view, ActionBar.LayoutParams layoutParams)
ActionBar
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 ActionBar.DISPLAY_SHOW_CUSTOM
must be set for
the custom view to be displayed.
setCustomView
in class ActionBar
view
- Custom navigation view to place in the ActionBar.layoutParams
- How this custom view should layout in the bar.ActionBar.setDisplayOptions(int, int)
public void setListNavigationCallbacks(android.widget.SpinnerAdapter adapter, ActionBar.OnNavigationListener callback)
ActionBar
setListNavigationCallbacks
in class ActionBar
adapter
- An adapter that will provide views both to display
the current navigation selection and populate views
within the dropdown navigation menu.callback
- An OnNavigationListener that will receive events when the user
selects a navigation item.public int getSelectedNavigationIndex()
ActionBar
getSelectedNavigationIndex
in class ActionBar
public int getNavigationItemCount()
ActionBar
getNavigationItemCount
in class ActionBar
public int getTabCount()
ActionBar
getTabCount
in class ActionBar
public void setNavigationMode(int mode)
ActionBar
setNavigationMode
in class ActionBar
mode
- The new mode to set.ActionBar.NAVIGATION_MODE_STANDARD
,
ActionBar.NAVIGATION_MODE_LIST
,
ActionBar.NAVIGATION_MODE_TABS
public ActionBar.Tab getTabAt(int index)
ActionBar
public void setIcon(int resId)
ActionBar
ActionBar.DISPLAY_USE_LOGO
.setIcon
in class ActionBar
resId
- Resource ID of a drawable to show as an icon.ActionBar.setDisplayUseLogoEnabled(boolean)
,
ActionBar.setDisplayShowHomeEnabled(boolean)
public void setIcon(android.graphics.drawable.Drawable icon)
ActionBar
ActionBar.DISPLAY_USE_LOGO
.setIcon
in class ActionBar
icon
- Drawable to show as an icon.ActionBar.setDisplayUseLogoEnabled(boolean)
,
ActionBar.setDisplayShowHomeEnabled(boolean)
public void setLogo(int resId)
ActionBar
ActionBar.DISPLAY_USE_LOGO
.setLogo
in class ActionBar
resId
- Resource ID of a drawable to show as a logo.ActionBar.setDisplayUseLogoEnabled(boolean)
,
ActionBar.setDisplayShowHomeEnabled(boolean)
public void setLogo(android.graphics.drawable.Drawable logo)
ActionBar
ActionBar.DISPLAY_USE_LOGO
.setLogo
in class ActionBar
logo
- Drawable to show as a logo.ActionBar.setDisplayUseLogoEnabled(boolean)
,
ActionBar.setDisplayShowHomeEnabled(boolean)
Copyright © 2011–2014. All rights reserved.