public abstract class ActionBarSherlock extends Object
Helper for implementing the action bar design pattern across all versions of Android.
This class will manage interaction with a custom action bar based on the Android 4.0 source code. The exposed API mirrors that of its native counterpart and you should refer to its documentation for instruction.
Modifier and Type | Class and Description |
---|---|
static interface |
ActionBarSherlock.Implementation
Denotes an implementation of ActionBarSherlock which provides an
action bar-enhanced experience.
|
static interface |
ActionBarSherlock.OnActionModeFinishedListener
Activity interface for action mode finished callback.
|
static interface |
ActionBarSherlock.OnActionModeStartedListener
Activity interface for action mode started callback.
|
static interface |
ActionBarSherlock.OnCreateOptionsMenuListener
Activity interface for menu creation callback.
|
static interface |
ActionBarSherlock.OnCreatePanelMenuListener
Activity interface for menu creation callback.
|
static interface |
ActionBarSherlock.OnMenuItemSelectedListener
Activity interface for menu item selection callback.
|
static interface |
ActionBarSherlock.OnOptionsItemSelectedListener
Activity interface for menu item selection callback.
|
static interface |
ActionBarSherlock.OnPrepareOptionsMenuListener
Activity interface for menu preparation callback.
|
static interface |
ActionBarSherlock.OnPreparePanelListener
Activity interface for menu preparation callback.
|
Modifier and Type | Field and Description |
---|---|
protected static boolean |
DEBUG |
static int |
FLAG_DELEGATE
If set, the logic in these classes will assume that an
Activity
is dispatching all of the required events to the class. |
protected android.app.Activity |
mActivity
Activity which is displaying the action bar.
|
protected boolean |
mIsDelegate
Whether delegating actions for the activity or managing ourselves.
|
protected MenuInflater |
mMenuInflater
Reference to our custom menu inflater which supports action items.
|
protected static String |
TAG |
Modifier | Constructor and Description |
---|---|
protected |
ActionBarSherlock(android.app.Activity activity,
int flags) |
Modifier and Type | Method and Description |
---|---|
abstract void |
addContentView(android.view.View view,
android.view.ViewGroup.LayoutParams params)
Variation on
setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
to add an additional content view to the screen. |
protected boolean |
callbackCreateOptionsMenu(Menu menu)
Internal method to trigger the menu creation process.
|
protected boolean |
callbackOptionsItemSelected(MenuItem item)
Internal method for dispatching options menu selection to the owning
activity callback.
|
protected boolean |
callbackPrepareOptionsMenu(Menu menu)
Internal method to trigger the menu preparation process.
|
boolean |
dispatchCloseOptionsMenu()
Notify the action bar that it should close its overflow menu if it is
appropriate for the device.
|
void |
dispatchConfigurationChanged(android.content.res.Configuration newConfig)
Notify action bar of a configuration change event.
|
abstract boolean |
dispatchCreateOptionsMenu(android.view.Menu menu)
Notify the action bar that the Activity has triggered a menu creation
which should happen on the conclusion of
Activity.onCreate(android.os.Bundle) . |
void |
dispatchDestroy()
Notify the action bar that the activity has been destroyed.
|
abstract void |
dispatchInvalidateOptionsMenu()
Indicate that the menu should be recreated by calling
ActionBarSherlock.OnCreateOptionsMenuListener.onCreateOptionsMenu(com.actionbarsherlock.view.Menu) . |
boolean |
dispatchKeyEvent(android.view.KeyEvent event)
Notify the action bar the user has created a key event.
|
boolean |
dispatchMenuOpened(int featureId,
android.view.Menu menu)
Notify the action bar that the overflow menu has been opened.
|
boolean |
dispatchOpenOptionsMenu()
Notify the action bar that it should display its overflow menu if it is
appropriate for the device.
|
abstract boolean |
dispatchOptionsItemSelected(android.view.MenuItem item)
Notify the action bar that a native options menu item has been selected.
|
void |
dispatchPanelClosed(int featureId,
android.view.Menu menu)
Notify the action bar that the overflow menu has been closed.
|
void |
dispatchPause()
Notify the action bar that the activity is pausing.
|
void |
dispatchPostCreate(android.os.Bundle savedInstanceState)
Notify the class that the activity has finished its creation.
|
void |
dispatchPostResume()
Notify the action bar that the activity has finished its resuming.
|
abstract boolean |
dispatchPrepareOptionsMenu(android.view.Menu menu)
Notify the action bar that the Activity has triggered a menu preparation
which usually means that the user has requested the overflow menu via a
hardware menu key.
|
void |
dispatchStop()
Notify the action bar that the activity is stopping.
|
void |
dispatchTitleChanged(CharSequence title,
int color)
Notify the action bar that the title has changed and the action bar
should be updated to reflect the change.
|
abstract ActionBar |
getActionBar()
Get the current action bar instance.
|
MenuInflater |
getMenuInflater()
Get a menu inflater instance which supports the newer menu attributes.
|
protected abstract android.content.Context |
getThemedContext() |
abstract boolean |
hasFeature(int featureId)
Query for the availability of a certain feature.
|
static void |
registerImplementation(Class<? extends ActionBarSherlock> implementationClass)
Register an ActionBarSherlock implementation.
|
abstract boolean |
requestFeature(int featureId)
Enable extended screen features.
|
abstract void |
setContentView(int layoutResId)
Set the content of the activity inside the action bar.
|
void |
setContentView(android.view.View view)
Set the content of the activity inside the action bar.
|
abstract void |
setContentView(android.view.View view,
android.view.ViewGroup.LayoutParams params)
Set the content of the activity inside the action bar.
|
abstract void |
setProgress(int progress)
Sets the progress for the progress bars in the title.
|
abstract void |
setProgressBarIndeterminate(boolean indeterminate)
Sets whether the horizontal progress bar in the title should be indeterminate (the circular
is always indeterminate).
|
abstract void |
setProgressBarIndeterminateVisibility(boolean visible)
Sets the visibility of the indeterminate progress bar in the title.
|
abstract void |
setProgressBarVisibility(boolean visible)
Sets the visibility of the progress bar in the title.
|
abstract void |
setSecondaryProgress(int secondaryProgress)
Sets the secondary progress for the progress bar in the title.
|
abstract void |
setTitle(CharSequence title)
Change the title associated with this activity.
|
void |
setTitle(int resId)
Change the title associated with this activity.
|
abstract void |
setUiOptions(int uiOptions)
Set extra options that will influence the UI for this window.
|
abstract void |
setUiOptions(int uiOptions,
int mask)
Set extra options that will influence the UI for this window.
|
abstract ActionMode |
startActionMode(ActionMode.Callback callback)
Start an action mode.
|
static boolean |
unregisterImplementation(Class<? extends ActionBarSherlock> implementationClass)
Unregister an ActionBarSherlock implementation.
|
static ActionBarSherlock |
wrap(android.app.Activity activity)
Wrap an activity with an action bar abstraction which will enable the
use of a custom implementation on platforms where a native version does
not exist.
|
static ActionBarSherlock |
wrap(android.app.Activity activity,
int flags)
Wrap an activity with an action bar abstraction which will enable the
use of a custom implementation on platforms where a native version does
not exist.
|
protected static final String TAG
protected static final boolean DEBUG
public static final int FLAG_DELEGATE
Activity
is dispatching all of the required events to the class. This flag should
only be used internally or if you are creating your own base activity
modeled after one of the included types (e.g., SherlockActivity
).protected final android.app.Activity mActivity
protected final boolean mIsDelegate
protected MenuInflater mMenuInflater
protected ActionBarSherlock(android.app.Activity activity, int flags)
public static void registerImplementation(Class<? extends ActionBarSherlock> implementationClass)
implementationClass
- Target implementation class which extends
ActionBarSherlock
. This class must also be annotated with
ActionBarSherlock.Implementation
.public static boolean unregisterImplementation(Class<? extends ActionBarSherlock> implementationClass)
implementationClass
- Target implementation class.public static ActionBarSherlock wrap(android.app.Activity activity)
activity
- Activity to wrap.public static ActionBarSherlock wrap(android.app.Activity activity, int flags)
activity
- Owning activity.flags
- Option flags to control behavior.public abstract ActionBar getActionBar()
public void dispatchConfigurationChanged(android.content.res.Configuration newConfig)
newConfig
- The new device configuration.public void dispatchPostResume()
public void dispatchPause()
public void dispatchStop()
public abstract void dispatchInvalidateOptionsMenu()
ActionBarSherlock.OnCreateOptionsMenuListener.onCreateOptionsMenu(com.actionbarsherlock.view.Menu)
.public boolean dispatchOpenOptionsMenu()
false
.
true
if the opening of the menu was handled internally.public boolean dispatchCloseOptionsMenu()
false
.
true
if the closing of the menu was handled internally.public void dispatchPostCreate(android.os.Bundle savedInstanceState)
savedInstanceState
- If the activity is being re-initialized after
previously being shut down then this Bundle
contains the data it most recently supplied in
Activity#
onSaveInstanceState(Bundle)}.
Note: Otherwise it is null.public void dispatchTitleChanged(CharSequence title, int color)
title
- New activity title.color
- New activity color.public boolean dispatchKeyEvent(android.view.KeyEvent event)
event
- Description of the key event.true
if the event was handled.public abstract boolean dispatchCreateOptionsMenu(android.view.Menu menu)
Activity.onCreate(android.os.Bundle)
. This
will be used to gain a reference to the native menu for native and
overflow binding as well as to indicate when compatibility create should
occur for the first time.menu
- Activity native menu.true
since we always want to say that we have a nativepublic abstract boolean dispatchPrepareOptionsMenu(android.view.Menu menu)
menu
- Activity native menu.true
if menu display should proceed.public abstract boolean dispatchOptionsItemSelected(android.view.MenuItem item)
item
- Options menu item.public boolean dispatchMenuOpened(int featureId, android.view.Menu menu)
true
if this method
returns true
, otherwise return the result of the superclass
method.
featureId
- Window feature which triggered the event.menu
- Activity native menu.true
if the event was handled by this method.public void dispatchPanelClosed(int featureId, android.view.Menu menu)
featureId
- menu
- public void dispatchDestroy()
protected final boolean callbackCreateOptionsMenu(Menu menu)
true
if menu creation should proceed.protected final boolean callbackPrepareOptionsMenu(Menu menu)
true
if menu preparation should proceed.protected final boolean callbackOptionsItemSelected(MenuItem item)
item
- Selected options menu item.true
if the item selection was handled in the callback.public abstract boolean hasFeature(int featureId)
featureId
- The feature ID to check.true
if feature is enabled, false
otherwise.public abstract boolean requestFeature(int featureId)
setContentView()
. May be called as many times as desired as long
as it is before setContentView()
. If not called, no extended
features will be available. You can not turn off a feature once it is
requested.featureId
- The desired features, defined as constants by Window.public abstract void setUiOptions(int uiOptions)
uiOptions
- Flags specifying extra options for this window.public abstract void setUiOptions(int uiOptions, int mask)
uiOptions
- Flags specifying extra options for this window.mask
- Flags specifying which options should be modified. Others
will remain unchanged.public abstract void setContentView(int layoutResId)
layoutResId
- Layout resource ID.public void setContentView(android.view.View view)
view
- The desired content to display.public abstract void setContentView(android.view.View view, android.view.ViewGroup.LayoutParams params)
view
- The desired content to display.params
- Layout parameters to apply to the view.public abstract void addContentView(android.view.View view, android.view.ViewGroup.LayoutParams params)
setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
to add an additional content view to the screen. Added after any
existing ones on the screen -- existing views are NOT removed.view
- The desired content to display.params
- Layout parameters for the view.public abstract void setTitle(CharSequence title)
public void setTitle(int resId)
public abstract void setProgressBarVisibility(boolean visible)
In order for the progress bar to be shown, the feature must be requested
via #requestWindowFeature(int)
.
visible
- Whether to show the progress bars in the title.public abstract void setProgressBarIndeterminateVisibility(boolean visible)
In order for the progress bar to be shown, the feature must be requested
via #requestWindowFeature(int)
.
visible
- Whether to show the progress bars in the title.public abstract void setProgressBarIndeterminate(boolean indeterminate)
In order for the progress bar to be shown, the feature must be requested
via #requestWindowFeature(int)
.
indeterminate
- Whether the horizontal progress bar should be indeterminate.public abstract void setProgress(int progress)
In order for the progress bar to be shown, the feature must be requested
via #requestWindowFeature(int)
.
progress
- The progress for the progress bar. Valid ranges are from
0 to 10000 (both inclusive). If 10000 is given, the progress
bar will be completely filled and will fade out.public abstract void setSecondaryProgress(int secondaryProgress)
setProgress(int)
and the background. It can be ideal for media
scenarios such as showing the buffering progress while the default
progress shows the play progress.
In order for the progress bar to be shown, the feature must be requested
via #requestWindowFeature(int)
.
secondaryProgress
- The secondary progress for the progress bar. Valid ranges are from
0 to 10000 (both inclusive).public MenuInflater getMenuInflater()
protected abstract android.content.Context getThemedContext()
public abstract ActionMode startActionMode(ActionMode.Callback callback)
callback
- Callback that will manage lifecycle events for this
context mode.ActionMode
Copyright © 2011–2014. All rights reserved.