Fields Summary |
---|
private static final String | TAG |
public static final int | SHOW_AS_ACTION_NEVERNever show this item as a button in an Action Bar. |
public static final int | SHOW_AS_ACTION_IF_ROOMShow this item as a button in an Action Bar if the system
decides there is room for it. |
public static final int | SHOW_AS_ACTION_ALWAYSAlways show this item as a button in an Action Bar. Use sparingly!
If too many items are set to always show in the Action Bar it can
crowd the Action Bar and degrade the user experience on devices with
smaller screens. A good rule of thumb is to have no more than 2
items set to always show at a time. |
public static final int | SHOW_AS_ACTION_WITH_TEXTWhen this item is in the action bar, always show it with a
text label even if it also has an icon specified. |
public static final int | SHOW_AS_ACTION_COLLAPSE_ACTION_VIEWThis item's action view collapses to a normal menu item.
When expanded, the action view temporarily takes over
a larger segment of its container. |
static final MenuVersionImpl | IMPLSelect the correct implementation to use for the current platform. |
Methods Summary |
---|
public static boolean | collapseActionView(android.view.MenuItem item)Collapse the action view associated with this menu item. The menu item must have an action
view set, as well as the showAsAction flag {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. If a
listener has been set using {@link #setOnActionExpandListener(MenuItem,
android.support.v4.view.MenuItemCompat.OnActionExpandListener)}
it will have its {@link
android.support.v4.view.MenuItemCompat.OnActionExpandListener#onMenuItemActionCollapse(MenuItem)}
method invoked. The listener may return false from this method to prevent collapsing
the action view.
if (item instanceof SupportMenuItem) {
return ((SupportMenuItem) item).collapseActionView();
}
return IMPL.collapseActionView(item);
|
public static boolean | expandActionView(android.view.MenuItem item)Expand the action view associated with this menu item.
The menu item must have an action view set, as well as
the showAsAction flag {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}.
If a listener has been set using
{@link #setOnActionExpandListener(MenuItem, OnActionExpandListener)}
it will have its {@link OnActionExpandListener#onMenuItemActionExpand(MenuItem)}
method invoked. The listener may return false from this method to prevent expanding
the action view.
if (item instanceof SupportMenuItem) {
return ((SupportMenuItem) item).expandActionView();
}
return IMPL.expandActionView(item);
|
public static ActionProvider | getActionProvider(android.view.MenuItem item)Gets the {@link ActionProvider}.
if (item instanceof SupportMenuItem) {
return ((SupportMenuItem) item).getSupportActionProvider();
}
// TODO Wrap the framework ActionProvider and return it
Log.w(TAG, "getActionProvider: item does not implement SupportMenuItem; returning null");
return null;
|
public static android.view.View | getActionView(android.view.MenuItem item)Returns the currently set action view for this menu item.
if (item instanceof SupportMenuItem) {
return ((SupportMenuItem) item).getActionView();
}
return IMPL.getActionView(item);
|
public static boolean | isActionViewExpanded(android.view.MenuItem item)Returns true if this menu item's action view has been expanded.
if (item instanceof SupportMenuItem) {
return ((SupportMenuItem) item).isActionViewExpanded();
}
return IMPL.isActionViewExpanded(item);
|
public static android.view.MenuItem | setActionProvider(android.view.MenuItem item, ActionProvider provider)Sets the {@link ActionProvider} responsible for creating an action view if
the item is placed on the action bar. The provider also provides a default
action invoked if the item is placed in the overflow menu.
Note: Setting an action provider overrides the action view
set via {@link #setActionView(MenuItem, View)}.
if (item instanceof SupportMenuItem) {
return ((SupportMenuItem) item).setSupportActionProvider(provider);
}
// TODO Wrap the support ActionProvider and assign it
Log.w(TAG, "setActionProvider: item does not implement SupportMenuItem; ignoring");
return item;
|
public static android.view.MenuItem | setActionView(android.view.MenuItem item, android.view.View view)Set an action view for this menu item. An action view will be displayed in place
of an automatically generated menu item element in the UI when this item is shown
as an action within a parent.
if (item instanceof SupportMenuItem) {
return ((SupportMenuItem) item).setActionView(view);
}
return IMPL.setActionView(item, view);
|
public static android.view.MenuItem | setActionView(android.view.MenuItem item, int resId)Set an action view for this menu item. An action view will be displayed in place
of an automatically generated menu item element in the UI when this item is shown
as an action within a parent.
Note: Setting an action view overrides the action provider
set via {@link #setActionProvider(MenuItem, ActionProvider)}.
if (item instanceof SupportMenuItem) {
return ((SupportMenuItem) item).setActionView(resId);
}
return IMPL.setActionView(item, resId);
|
public static android.view.MenuItem | setOnActionExpandListener(android.view.MenuItem item, android.support.v4.view.MenuItemCompat$OnActionExpandListener listener)Set an {@link OnActionExpandListener} on this menu
item to be notified when the associated action view is expanded or collapsed.
The menu item must be configured to expand or collapse its action view using the flag
{@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}.
if (item instanceof SupportMenuItem) {
return ((SupportMenuItem) item).setSupportOnActionExpandListener(listener);
}
return IMPL.setOnActionExpandListener(item, listener);
|
public static void | setShowAsAction(android.view.MenuItem item, int actionEnum)Sets how this item should display in the presence of a compatible Action Bar. If the given
item is compatible, this will call the item's supported implementation of
{@link MenuItem#setShowAsAction(int)}.
final int version = android.os.Build.VERSION.SDK_INT;
if (version >= 14) {
IMPL = new IcsMenuVersionImpl();
} else if (version >= 11) {
IMPL = new HoneycombMenuVersionImpl();
} else {
IMPL = new BaseMenuVersionImpl();
}
if (item instanceof SupportMenuItem) {
((SupportMenuItem) item).setShowAsAction(actionEnum);
} else {
IMPL.setShowAsAction(item, actionEnum);
}
|