Methods Summary |
---|
public void | actionFormatChanged()
mMenu.onItemActionRequestChanged(this);
|
public boolean | collapseActionView()
if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0) {
return false;
}
if (mActionView == null) {
// We're already collapsed if we have no action view.
return true;
}
if (mOnActionExpandListener == null ||
mOnActionExpandListener.onMenuItemActionCollapse(this)) {
return mMenu.collapseItemActionView(this);
}
return false;
|
public boolean | expandActionView()
if (!hasCollapsibleActionView()) {
return false;
}
if (mOnActionExpandListener == null ||
mOnActionExpandListener.onMenuItemActionExpand(this)) {
return mMenu.expandItemActionView(this);
}
return false;
|
public android.view.ActionProvider | getActionProvider()
throw new UnsupportedOperationException(
"This is not supported, use MenuItemCompat.getActionProvider()");
|
public android.view.View | getActionView()
if (mActionView != null) {
return mActionView;
} else if (mActionProvider != null) {
mActionView = mActionProvider.onCreateActionView(this);
return mActionView;
} else {
return null;
}
|
public char | getAlphabeticShortcut()
return mShortcutAlphabeticChar;
|
java.lang.Runnable | getCallback()
return mItemCallback;
|
public int | getGroupId()
return mGroup;
|
public android.graphics.drawable.Drawable | getIcon()
if (mIconDrawable != null) {
return mIconDrawable;
}
if (mIconResId != NO_ICON) {
Drawable icon = TintManager.getDrawable(mMenu.getContext(), mIconResId);
mIconResId = NO_ICON;
mIconDrawable = icon;
return icon;
}
return null;
|
public android.content.Intent | getIntent()
return mIntent;
|
public int | getItemId()
return mId;
|
public android.view.ContextMenu.ContextMenuInfo | getMenuInfo()
return mMenuInfo;
|
public char | getNumericShortcut()
return mShortcutNumericChar;
|
public int | getOrder()
return mCategoryOrder;
|
public int | getOrdering()
return mOrdering;
|
char | getShortcut()
return (mMenu.isQwertyMode() ? mShortcutAlphabeticChar : mShortcutNumericChar);
|
java.lang.String | getShortcutLabel()
char shortcut = getShortcut();
if (shortcut == 0) {
return "";
}
StringBuilder sb = new StringBuilder(sPrependShortcutLabel);
switch (shortcut) {
case '\n":
sb.append(sEnterShortcutLabel);
break;
case '\b":
sb.append(sDeleteShortcutLabel);
break;
case ' ":
sb.append(sSpaceShortcutLabel);
break;
default:
sb.append(shortcut);
break;
}
return sb.toString();
|
public android.view.SubMenu | getSubMenu()
return mSubMenu;
|
public android.support.v4.view.ActionProvider | getSupportActionProvider()
return mActionProvider;
|
public java.lang.CharSequence | getTitle()
return mTitle;
|
public java.lang.CharSequence | getTitleCondensed()
final CharSequence ctitle = mTitleCondensed != null ? mTitleCondensed : mTitle;
if (Build.VERSION.SDK_INT < 18 && ctitle != null && !(ctitle instanceof String)) {
// For devices pre-JB-MR2, where we have a non-String CharSequence, we need to
// convert this to a String so that EventLog.writeEvent() does not throw an exception
// in Activity.onMenuItemSelected()
return ctitle.toString();
} else {
// Else, we just return the condensed title
return ctitle;
}
|
java.lang.CharSequence | getTitleForItemView(MenuView.ItemView itemView)Gets the title for a particular {@link MenuView.ItemView}
return ((itemView != null) && itemView.prefersCondensedTitle())
? getTitleCondensed()
: getTitle();
|
public boolean | hasCollapsibleActionView()
if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) != 0) {
if (mActionView == null && mActionProvider != null) {
mActionView = mActionProvider.onCreateActionView(this);
}
return mActionView != null;
}
return false;
|
public boolean | hasSubMenu()
return mSubMenu != null;
|
public boolean | invoke()Invokes the item by calling various listeners or callbacks.
if (mClickListener != null && mClickListener.onMenuItemClick(this)) {
return true;
}
if (mMenu.dispatchMenuItemSelected(mMenu.getRootMenu(), this)) {
return true;
}
if (mItemCallback != null) {
mItemCallback.run();
return true;
}
if (mIntent != null) {
try {
mMenu.getContext().startActivity(mIntent);
return true;
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Can't find activity to handle intent; ignoring", e);
}
}
if (mActionProvider != null && mActionProvider.onPerformDefaultAction()) {
return true;
}
return false;
|
public boolean | isActionButton()
return (mFlags & IS_ACTION) == IS_ACTION;
|
public boolean | isActionViewExpanded()
return mIsActionViewExpanded;
|
public boolean | isCheckable()
return (mFlags & CHECKABLE) == CHECKABLE;
|
public boolean | isChecked()
return (mFlags & CHECKED) == CHECKED;
|
public boolean | isEnabled()
return (mFlags & ENABLED) != 0;
|
public boolean | isExclusiveCheckable()
return (mFlags & EXCLUSIVE) != 0;
|
public boolean | isVisible()
if (mActionProvider != null && mActionProvider.overridesItemVisibility()) {
return (mFlags & HIDDEN) == 0 && mActionProvider.isVisible();
}
return (mFlags & HIDDEN) == 0;
|
public boolean | requestsActionButton()
return (mShowAsAction & SHOW_AS_ACTION_IF_ROOM) == SHOW_AS_ACTION_IF_ROOM;
|
public boolean | requiresActionButton()
return (mShowAsAction & SHOW_AS_ACTION_ALWAYS) == SHOW_AS_ACTION_ALWAYS;
|
public android.view.MenuItem | setActionProvider(android.view.ActionProvider actionProvider)
throw new UnsupportedOperationException(
"This is not supported, use MenuItemCompat.setActionProvider()");
|
public android.support.v4.internal.view.SupportMenuItem | setActionView(android.view.View view)
mActionView = view;
mActionProvider = null;
if (view != null && view.getId() == View.NO_ID && mId > 0) {
view.setId(mId);
}
mMenu.onItemActionRequestChanged(this);
return this;
|
public android.support.v4.internal.view.SupportMenuItem | setActionView(int resId)
final Context context = mMenu.getContext();
final LayoutInflater inflater = LayoutInflater.from(context);
setActionView(inflater.inflate(resId, new LinearLayout(context), false));
return this;
|
public void | setActionViewExpanded(boolean isExpanded)
mIsActionViewExpanded = isExpanded;
mMenu.onItemsChanged(false);
|
public android.view.MenuItem | setAlphabeticShortcut(char alphaChar)
if (mShortcutAlphabeticChar == alphaChar) {
return this;
}
mShortcutAlphabeticChar = Character.toLowerCase(alphaChar);
mMenu.onItemsChanged(false);
return this;
|
public android.view.MenuItem | setCallback(java.lang.Runnable callback)
mItemCallback = callback;
return this;
|
public android.view.MenuItem | setCheckable(boolean checkable)
final int oldFlags = mFlags;
mFlags = (mFlags & ~CHECKABLE) | (checkable ? CHECKABLE : 0);
if (oldFlags != mFlags) {
mMenu.onItemsChanged(false);
}
return this;
|
public android.view.MenuItem | setChecked(boolean checked)
if ((mFlags & EXCLUSIVE) != 0) {
// Call the method on the Menu since it knows about the others in this
// exclusive checkable group
mMenu.setExclusiveItemChecked(this);
} else {
setCheckedInt(checked);
}
return this;
|
void | setCheckedInt(boolean checked)
final int oldFlags = mFlags;
mFlags = (mFlags & ~CHECKED) | (checked ? CHECKED : 0);
if (oldFlags != mFlags) {
mMenu.onItemsChanged(false);
}
|
public android.view.MenuItem | setEnabled(boolean enabled)
if (enabled) {
mFlags |= ENABLED;
} else {
mFlags &= ~ENABLED;
}
mMenu.onItemsChanged(false);
return this;
|
public void | setExclusiveCheckable(boolean exclusive)
mFlags = (mFlags & ~EXCLUSIVE) | (exclusive ? EXCLUSIVE : 0);
|
public android.view.MenuItem | setIcon(android.graphics.drawable.Drawable icon)
mIconResId = NO_ICON;
mIconDrawable = icon;
mMenu.onItemsChanged(false);
return this;
|
public android.view.MenuItem | setIcon(int iconResId)
mIconDrawable = null;
mIconResId = iconResId;
// If we have a view, we need to push the Drawable to them
mMenu.onItemsChanged(false);
return this;
|
public android.view.MenuItem | setIntent(android.content.Intent intent)
mIntent = intent;
return this;
|
public void | setIsActionButton(boolean isActionButton)
if (isActionButton) {
mFlags |= IS_ACTION;
} else {
mFlags &= ~IS_ACTION;
}
|
void | setMenuInfo(android.view.ContextMenu.ContextMenuInfo menuInfo)
mMenuInfo = menuInfo;
|
public android.view.MenuItem | setNumericShortcut(char numericChar)
if (mShortcutNumericChar == numericChar) {
return this;
}
mShortcutNumericChar = numericChar;
mMenu.onItemsChanged(false);
return this;
|
public android.view.MenuItem | setOnActionExpandListener(MenuItem.OnActionExpandListener listener)
throw new UnsupportedOperationException(
"This is not supported, use MenuItemCompat.setOnActionExpandListener()");
|
public android.view.MenuItem | setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener clickListener)
mClickListener = clickListener;
return this;
|
public android.view.MenuItem | setShortcut(char numericChar, char alphaChar)
mShortcutNumericChar = numericChar;
mShortcutAlphabeticChar = Character.toLowerCase(alphaChar);
mMenu.onItemsChanged(false);
return this;
|
public void | setShowAsAction(int actionEnum)
switch (actionEnum & SHOW_AS_ACTION_MASK) {
case SHOW_AS_ACTION_ALWAYS:
case SHOW_AS_ACTION_IF_ROOM:
case SHOW_AS_ACTION_NEVER:
// Looks good!
break;
default:
// Mutually exclusive options selected!
throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM,"
+ " and SHOW_AS_ACTION_NEVER are mutually exclusive.");
}
mShowAsAction = actionEnum;
mMenu.onItemActionRequestChanged(this);
|
public android.support.v4.internal.view.SupportMenuItem | setShowAsActionFlags(int actionEnum)
setShowAsAction(actionEnum);
return this;
|
void | setSubMenu(SubMenuBuilder subMenu)
mSubMenu = subMenu;
subMenu.setHeaderTitle(getTitle());
|
public android.support.v4.internal.view.SupportMenuItem | setSupportActionProvider(android.support.v4.view.ActionProvider actionProvider)
if (mActionProvider != null) {
mActionProvider.setVisibilityListener(null);
}
mActionView = null;
mActionProvider = actionProvider;
mMenu.onItemsChanged(true); // Measurement can be changed
if (mActionProvider != null) {
mActionProvider.setVisibilityListener(new ActionProvider.VisibilityListener() {
@Override
public void onActionProviderVisibilityChanged(boolean isVisible) {
mMenu.onItemVisibleChanged(MenuItemImpl.this);
}
});
}
return this;
|
public android.support.v4.internal.view.SupportMenuItem | setSupportOnActionExpandListener(MenuItemCompat.OnActionExpandListener listener)
mOnActionExpandListener = listener;
return this;
|
public android.view.MenuItem | setTitle(java.lang.CharSequence title)
mTitle = title;
mMenu.onItemsChanged(false);
if (mSubMenu != null) {
mSubMenu.setHeaderTitle(title);
}
return this;
|
public android.view.MenuItem | setTitle(int title)
return setTitle(mMenu.getContext().getString(title));
|
public android.view.MenuItem | setTitleCondensed(java.lang.CharSequence title)
mTitleCondensed = title;
// Could use getTitle() in the loop below, but just cache what it would do here
if (title == null) {
title = mTitle;
}
mMenu.onItemsChanged(false);
return this;
|
public android.view.MenuItem | setVisible(boolean shown)
// Try to set the shown state to the given state. If the shown state was changed
// (i.e. the previous state isn't the same as given state), notify the parent menu that
// the shown state has changed for this item
if (setVisibleInt(shown)) mMenu.onItemVisibleChanged(this);
return this;
|
boolean | setVisibleInt(boolean shown)Changes the visibility of the item. This method DOES NOT notify the parent menu of a change
in this item, so this should only be called from methods that will eventually trigger this
change. If unsure, use {@link #setVisible(boolean)} instead.
final int oldFlags = mFlags;
mFlags = (mFlags & ~HIDDEN) | (shown ? 0 : HIDDEN);
return oldFlags != mFlags;
|
public boolean | shouldShowIcon()
return mMenu.getOptionalIconsVisible();
|
boolean | shouldShowShortcut()
// Show shortcuts if the menu is supposed to show shortcuts AND this item has a shortcut
return mMenu.isShortcutsVisible() && (getShortcut() != 0);
|
public boolean | showsTextAsAction()
return (mShowAsAction & SHOW_AS_ACTION_WITH_TEXT) == SHOW_AS_ACTION_WITH_TEXT;
|
public java.lang.String | toString()
return mTitle.toString();
|