/** * Gets the title for a particular {@link ItemView} * * @param itemView The ItemView that is receiving the title * @return Either the title or condensed title based on what the ItemView * prefers */ CharSequence getTitleForItemView(MenuView.ItemView itemView) { return ((itemView != null) && itemView.prefersCondensedTitle()) ? getTitleCondensed() : getTitle(); }
void setSubMenu(SubMenuBuilder subMenu) { mSubMenu = subMenu; subMenu.setHeaderTitle(getTitle()); }
/** * Gets the title for a particular {@link ItemView} * * @param itemView The ItemView that is receiving the title * @return Either the title or condensed title based on what the ItemView * prefers */ CharSequence getTitleForItemView(MenuView.ItemView itemView) { return ((itemView != null) && itemView.prefersCondensedTitle()) ? getTitleCondensed() : getTitle(); }
void setSubMenu(SubMenuBuilder subMenu) { mSubMenu = subMenu; subMenu.setHeaderTitle(getTitle()); }
if (nonActionItem.hasSubMenu()) { android.view.SubMenu nativeSub = menu.addSubMenu(nonActionItem.getGroupId(), nonActionItem.getItemId(), nonActionItem.getOrder(), nonActionItem.getTitle()); subItem.getOrder(), subItem.getTitle()); } else { nativeItem = menu.add(nonActionItem.getGroupId(), nonActionItem.getItemId(), nonActionItem.getOrder(), nonActionItem.getTitle());
@Override public boolean onLongClick(View v) { if (hasText()) { // Don't show the cheat sheet for items that already show text. return false; } final int[] screenPos = new int[2]; final Rect displayFrame = new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context = getContext(); final int width = getWidth(); final int height = getHeight(); final int midy = screenPos[1] + height / 2; final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { // Show along the top; follow action buttons cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT, screenWidth - screenPos[0] - width / 2, height); } else { // Show along the bottom center cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height); } cheatSheet.show(); return true; }
if (nonActionItem.hasSubMenu()) { android.view.SubMenu nativeSub = menu.addSubMenu(nonActionItem.getGroupId(), nonActionItem.getItemId(), nonActionItem.getOrder(), nonActionItem.getTitle()); subItem.getOrder(), subItem.getTitle()); } else { nativeItem = menu.add(nonActionItem.getGroupId(), nonActionItem.getItemId(), nonActionItem.getOrder(), nonActionItem.getTitle());
@Override public boolean onLongClick(View v) { if (hasText()) { // Don't show the cheat sheet for items that already show text. return false; } final int[] screenPos = new int[2]; final Rect displayFrame = new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context = getContext(); final int width = getWidth(); final int height = getHeight(); final int midy = screenPos[1] + height / 2; final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; Toast cheatSheet = IcsToast.makeText(context, mItemData.getTitle(), IcsToast.LENGTH_SHORT); if (midy < displayFrame.height()) { // Show along the top; follow action buttons cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT, screenWidth - screenPos[0] - width / 2, height); } else { // Show along the bottom center cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height); } cheatSheet.show(); return true; }