コード例 #1
0
 @Override
 public void initialize(MenuItemImpl itemData, int menuType) {
   mItemData = itemData;
   setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE);
   setTitle(itemData.getTitleForItemView(this));
   setCheckable(itemData.isCheckable());
   setShortcut(itemData.shouldShowShortcut(), itemData.getShortcut());
   setIcon(itemData.getIcon());
   setEnabled(itemData.isEnabled());
 }
コード例 #2
0
  @Override
  public void setShortcut(boolean showShortcut, char shortcutKey) {
    final int newVisibility =
        showShortcut && mItemData.shouldShowShortcut() ? View.VISIBLE : View.GONE;

    if (newVisibility == View.VISIBLE) {
      mShortcutView.setText(mItemData.getShortcutLabel());
    }

    if (mShortcutView.getVisibility() != newVisibility) {
      mShortcutView.setVisibility(newVisibility);
    }
  }