android.support.v7.widget.PopupMenu类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中android.support.v7.widget.PopupMenu类的一些代码示例,展示了PopupMenu类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PopupMenu类的具体详情如下:
包路径:android.support.v7.widget.PopupMenu
类名称:PopupMenu

PopupMenu介绍

暂无

代码示例

代码示例来源:origin: aa112901/remusic

@Override
public void onClick(View v) {
  PopupMenu popupMenu = new PopupMenu(mContext, v);
  popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
  popupMenu.inflate(R.menu.popmenu);
  popupMenu.show();

代码示例来源:origin: hidroh/materialistic

@Override
public PopupMenu setMenuItemTitle(@IdRes int itemResId, @StringRes int title) {
  mSupportPopupMenu.getMenu().findItem(itemResId).setTitle(title);
  return this;
}

代码示例来源:origin: mancj/MaterialSearchBar

private void inflateMenuRequest(int menuResource, int iconResId
) {
  int menuResource1 = menuResource;
  if (menuResource1 > 0) {
    ImageView menuIcon = findViewById(R.id.mt_menu);
    if (iconResId != -1) {
      menuIconRes = iconResId;
      menuIcon.setImageResource(menuIconRes);
    }
    RelativeLayout.LayoutParams params = (LayoutParams) searchIcon.getLayoutParams();
    params.rightMargin = (int) (48 * destiny);
    searchIcon.setLayoutParams(params);
    menuIcon.setVisibility(VISIBLE);
    menuIcon.setOnClickListener(this);
    popupMenu = new PopupMenu(getContext(), menuIcon);
    popupMenu.inflate(menuResource);
    popupMenu.setGravity(Gravity.RIGHT);
  }
}

代码示例来源:origin: w568w/fuckView

android.support.v7.widget.PopupMenu popupMenu = new android.support.v7.widget.PopupMenu(view.getContext(), view);
popupMenu.getMenu().add(R.string.popup_mark_it);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
  @Override
  public boolean onMenuItemClick(MenuItem item) {
popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
  @Override
  public void onDismiss(PopupMenu menu) {
popupMenu.setGravity(Gravity.CENTER);
view.setBackgroundColor(Color.argb(120, 255, 0, 0));
updateLayout();
popupMenu.show();

代码示例来源:origin: willowtreeapps/Hyperion-Android

private void showMenu(View anchor) {
  final Context context = anchor.getContext();
  if (popupMenu != null) {
    popupMenu.dismiss();
  }
  popupMenu = new PopupMenu(context, anchor);
  popupMenu.inflate(R.menu.hgc_menu_options);
  final Menu menu = popupMenu.getMenu();
  final MenuItem areHapticsEnabledItem = menu.findItem(R.id.menu_item_use_haptics);
  areHapticsEnabledItem.setChecked(detector.areHapticsEnabled());
  areHapticsEnabledItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      boolean areHapticsEnabled = !item.isChecked();
      item.setChecked(areHapticsEnabled);
      detector.setHapticsEnabled(areHapticsEnabled);
      return true;
    }
  });
  popupMenu.show();
}

代码示例来源:origin: bzsome/VirtualApp-x326

private void initMenu() {
  mPopupMenu = new PopupMenu(new ContextThemeWrapper(this, R.style.Theme_AppCompat_Light), mMenuView);
  Menu menu = mPopupMenu.getMenu();
  setIconEnable(menu, true);
  menu.add("用户管理").setIcon(R.drawable.ic_account).setOnMenuItemClickListener(item -> {
    return false;
  });
  mMenuView.setOnClickListener(v -> mPopupMenu.show());

代码示例来源:origin: yoinx/kernel_adiutor

public PopupCardView(Context context, final List<String> list) {
  super(context, R.layout.popup_cardview);
  this.list = list;
  if (list != null) {
    popup = new PopupMenu(getContext(), valueView);
    for (int i = 0; i < list.size(); i++)
      popup.getMenu().add(Menu.NONE, i, Menu.NONE, list.get(i));
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
      @Override
      public boolean onMenuItemClick(MenuItem item) {
        if (valueView != null) {
          valueText = list.get(item.getItemId()) + " ";
          valueView.setText(list.get(item.getItemId()) + " ");
        }
        if (onPopupCardListener != null)
          onPopupCardListener.onItemSelected(PopupCardView.this, item.getItemId());
        return false;
      }
    });
  }
  if (onPopupCardListener != null) setListener();
}

代码示例来源:origin: hidroh/materialistic

@Override
  public void show() {
    mSupportPopupMenu.show();
  }
}

代码示例来源:origin: SamThompson/BubbleActions

Menu menu = new PopupMenu(root.getContext(), null).getMenu();
MenuInflater inflater = new MenuInflater(root.getContext());
inflater.inflate(menuRes, menu);

代码示例来源:origin: hidroh/materialistic

@Override
public PopupMenu create(Context context, View anchor, int gravity) {
  mSupportPopupMenu = new android.support.v7.widget.PopupMenu(context, anchor, gravity);
  return this;
}

代码示例来源:origin: hidroh/materialistic

@Override
public PopupMenu setOnMenuItemClickListener(final OnMenuItemClickListener listener) {
  mSupportPopupMenu.setOnMenuItemClickListener(listener::onMenuItemClick);
  return this;
}

代码示例来源:origin: hidroh/materialistic

@Override
public PopupMenu inflate(@MenuRes int menuRes) {
  mSupportPopupMenu.inflate(menuRes);
  return this;
}

代码示例来源:origin: mancj/MaterialSearchBar

@Override
public void onClick(View v) {
  int id = v.getId();
  if (id == getId()) {
    if (!searchEnabled) {
      enableSearch();
    }
  } else if (id == R.id.mt_arrow) {
    disableSearch();
  } else if (id == R.id.mt_search) {
    if (listenerExists())
      onSearchActionListener.onButtonClicked(BUTTON_SPEECH);
  } else if (id == R.id.mt_clear) {
    searchEdit.setText("");
  } else if (id == R.id.mt_menu) {
    popupMenu.show();
  } else if (id == R.id.mt_nav)
    if (listenerExists()) {
      if (navIconShown) {
        onSearchActionListener.onButtonClicked(BUTTON_NAVIGATION);
      } else {
        onSearchActionListener.onButtonClicked(BUTTON_BACK);
      }
    }
}

代码示例来源:origin: seven332/EhViewer

PopupMenu popup = new PopupMenu(context, mOtherActions, Gravity.TOP);
mPopupMenu = popup;
popup.getMenuInflater().inflate(R.menu.scene_gallery_detail, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
  @Override
  public boolean onMenuItemClick(MenuItem item) {

代码示例来源:origin: seven332/EhViewer

ensurePopMenu();
if (mPopupMenu != null) {
  mPopupMenu.show();

代码示例来源:origin: hidroh/materialistic

@Override
public PopupMenu setMenuItemVisible(@IdRes int itemResId, boolean visible) {
  mSupportPopupMenu.getMenu().findItem(itemResId).setVisible(visible);
  return this;
}

代码示例来源:origin: k9mail/k-9

@Override
public void onClick(View view) {
  int id = view.getId();
  if (id == R.id.from) {
    onAddSenderToContacts();
  } else if (id == R.id.to || id == R.id.cc || id == R.id.bcc) {
    expand((TextView)view, ((TextView)view).getEllipsize() != null);
    layoutChanged();
  } else if (id == R.id.crypto_status_icon) {
    onCryptoClickListener.onCryptoClick();
  } else if (id == R.id.icon_single_message_options) {
    PopupMenu popupMenu = new PopupMenu(getContext(), view);
    popupMenu.setOnMenuItemClickListener(onMenuItemClickListener);
    popupMenu.inflate(R.menu.single_message_options);
    popupMenu.show();
  }
}

代码示例来源:origin: yoinx/kernel_adiutor

@Override
  public void onClick(View v) {
    if (popup != null) popup.show();
  }
});

代码示例来源:origin: iMeiji/Toutiao

holder.tv_extra.setText(tv_source + " - " + tv_comment_count + " - " + tv_datetime);
holder.iv_dots.setOnClickListener(view -> {
  PopupMenu popupMenu = new PopupMenu(context,
      holder.iv_dots, Gravity.END, 0, R.style.MyPopupMenu);
  popupMenu.inflate(R.menu.menu_share);
  popupMenu.setOnMenuItemClickListener(menu -> {
    int itemId = menu.getItemId();
    if (itemId == R.id.action_share) {
  popupMenu.show();
});

代码示例来源:origin: plusCubed/anticipate

void onTryButtonPressed() {
  mTryPopup.show();
  clearEditTextFocus();
}

相关文章