android.widget.PopupMenu.getMenu()方法的使用及代码示例

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

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

PopupMenu.getMenu介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

PopupMenu popup = new PopupMenu(getContext(), mImageButton);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.your_menu, popup.getMenu());

代码示例来源:origin: TeamNewPipe/NewPipe

ViewHolderItem(View view) {
  super(view);
  progress = new ProgressDrawable();
  ViewCompat.setBackground(itemView.findViewById(R.id.item_bkg), progress);
  status = itemView.findViewById(R.id.item_status);
  name = itemView.findViewById(R.id.item_name);
  icon = itemView.findViewById(R.id.item_icon);
  size = itemView.findViewById(R.id.item_size);
  name.setSelected(true);
  ImageView button = itemView.findViewById(R.id.item_more);
  popupMenu = buildPopup(button);
  button.setOnClickListener(v -> showPopupMenu());
  Menu menu = popupMenu.getMenu();
  start = menu.findItem(R.id.start);
  pause = menu.findItem(R.id.pause);
  open = menu.findItem(R.id.open);
  queue = menu.findItem(R.id.queue);
  showError = menu.findItem(R.id.error_message_view);
  delete = menu.findItem(R.id.delete);
  source = menu.findItem(R.id.source);
  checksum = menu.findItem(R.id.checksum);
  itemView.setOnClickListener((v) -> {
    if (item.mission instanceof FinishedMission)
      viewWithFileProvider(item.mission.getDownloadedFile());
  });
}

代码示例来源:origin: chrisk44/Hijacker

void showActionSelector(){
  PopupMenu popup = new PopupMenu(getActivity(), actionBtn);
  popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
  //add(groupId, itemId, order, title)
  int i;
  for(i=0;i<cmds.size();i++){
    popup.getMenu().add(cmds.get(i).getType(), i, i, cmds.get(i).getTitle());
  }
  popup.getMenu().add(-1, 0, i+1, getString(R.string.manage_actions));
  popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
    public boolean onMenuItemClick(android.view.MenuItem item){
      if(item.getGroupId()==-1){
        //Open actions manager
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        ft.replace(R.id.fragment1, new CustomActionManagerFragment());
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        ft.addToBackStack(null);
        ft.commitAllowingStateLoss();
      }else{
        onActionSelected(cmds.get(item.getItemId()));
      }
      return true;
    }
  });
  popup.show();
}
void showTargetSelector(){

代码示例来源:origin: naman14/Timber

menu.inflate(R.menu.popup_song);
menu.getMenu().findItem(R.id.popup_song_delete).setVisible(false);
menu.getMenu().findItem(R.id.popup_song_share).setVisible(false);
menu.show();

代码示例来源:origin: chrisk44/Hijacker

@Override
public void onItemClick(AdapterView<?> adapterView, View view, final int index, long l){
  PopupMenu popup = new PopupMenu(getActivity(), view);
  popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
  popup.getMenu().add(0, 0, 0, getString(R.string.edit));
  popup.getMenu().add(0, 1, 1, getString(R.string.delete));

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

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

代码示例来源:origin: chrisk44/Hijacker

void onSelectClick(View view){
  PopupMenu popup = new PopupMenu(getActivity(), view);
  popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
  int i = 0;
  for(AP ap : AP.APs){
    popup.getMenu().add(0, i, i, ap.toString());
    i++;
  popup.getMenu().add(1, i, i, "Custom");
  popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
    public boolean onMenuItemClick(android.view.MenuItem item) {

代码示例来源:origin: TeamNewPipe/NewPipe

public void buildQualityMenu() {
  if (qualityPopupMenu == null) return;
  qualityPopupMenu.getMenu().removeGroup(qualityPopupMenuGroupId);
  for (int i = 0; i < availableStreams.size(); i++) {
    VideoStream videoStream = availableStreams.get(i);
    qualityPopupMenu.getMenu().add(qualityPopupMenuGroupId, i, Menu.NONE,
        MediaFormat.getNameById(videoStream.getFormatId()) + " " + videoStream.resolution);
  }
  if (getSelectedVideoStream() != null) {
    qualityTextView.setText(getSelectedVideoStream().resolution);
  }
  qualityPopupMenu.setOnMenuItemClickListener(this);
  qualityPopupMenu.setOnDismissListener(this);
}

代码示例来源:origin: chrisk44/Hijacker

PopupMenu popup = new PopupMenu(getActivity(), view);
popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
int i = 0;
for(AP ap : AP.APs){
  popup.getMenu().add(0, i, i, ap.toString());
  if(ap.sec==UNKNOWN  || ap.sec==OPN){
    popup.getMenu().getItem(i).setEnabled(false);
popup.getMenu().add(1, i, i, "Custom");
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
  public boolean onMenuItemClick(android.view.MenuItem item) {

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

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

代码示例来源:origin: chrisk44/Hijacker

void showTargetSelector(){
  PopupMenu popup = new PopupMenu(getActivity(), targetBtn);
  popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
    i = 0;
    for(AP ap : AP.APs){
      popup.getMenu().add(TYPE_AP, i, i, ap.toString());
      if(selectedAction.requiresClients() && ap.clients.size()==0){
        popup.getMenu().findItem(i).setEnabled(false);
    i = 0;
    for(ST st : ST.STs){
      popup.getMenu().add(TYPE_ST, i, i, st.toString());
      if(selectedAction.requiresConnected() && st.bssid==null){
        popup.getMenu().findItem(i).setEnabled(false);
  if(popup.getMenu().size()>0) popup.show();

代码示例来源:origin: TeamNewPipe/NewPipe

private void buildPlaybackSpeedMenu() {
  if (playbackSpeedPopupMenu == null) return;
  playbackSpeedPopupMenu.getMenu().removeGroup(playbackSpeedPopupMenuGroupId);
  for (int i = 0; i < PLAYBACK_SPEEDS.length; i++) {
    playbackSpeedPopupMenu.getMenu().add(playbackSpeedPopupMenuGroupId, i, Menu.NONE, formatSpeed(PLAYBACK_SPEEDS[i]));
  }
  playbackSpeedTextView.setText(formatSpeed(getPlaybackSpeed()));
  playbackSpeedPopupMenu.setOnMenuItemClickListener(this);
  playbackSpeedPopupMenu.setOnDismissListener(this);
}

代码示例来源:origin: naman14/Timber

menu.show();
if (isPlaylist)
  menu.getMenu().findItem(R.id.popup_song_remove_playlist).setVisible(true);

代码示例来源:origin: TeamNewPipe/NewPipe

private void buildCaptionMenu(final List<String> availableLanguages) {
  if (captionPopupMenu == null) return;
  captionPopupMenu.getMenu().removeGroup(captionPopupMenuGroupId);
  MenuItem captionOffItem = captionPopupMenu.getMenu().add(captionPopupMenuGroupId,
      0, Menu.NONE, R.string.caption_none);
  captionOffItem.setOnMenuItemClickListener(menuItem -> {
    MenuItem captionItem = captionPopupMenu.getMenu().add(captionPopupMenuGroupId,
        i + 1, Menu.NONE, captionLanguage);
    captionItem.setOnMenuItemClickListener(menuItem -> {

代码示例来源:origin: TeamNewPipe/NewPipe

private void buildItemPopupMenu(final PlayQueueItem item, final View view) {
  final PopupMenu menu = new PopupMenu(this, view);
  final MenuItem remove = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, /*pos=*/0,
      Menu.NONE, R.string.play_queue_remove);
  remove.setOnMenuItemClickListener(menuItem -> {
    if (player == null) return false;
    final int index = player.getPlayQueue().indexOf(item);
    if (index != -1) player.getPlayQueue().remove(index);
    return true;
  });
  final MenuItem detail = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, /*pos=*/1,
      Menu.NONE, R.string.play_queue_stream_detail);
  detail.setOnMenuItemClickListener(menuItem -> {
    onOpenDetail(item.getServiceId(), item.getUrl(), item.getTitle());
    return true;
  });
  final MenuItem append = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, /*pos=*/2,
      Menu.NONE, R.string.append_playlist);
  append.setOnMenuItemClickListener(menuItem -> {
    openPlaylistAppendDialog(Collections.singletonList(item));
    return true;
  });
  final MenuItem share = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, /*pos=*/3,
      Menu.NONE, R.string.share);
  share.setOnMenuItemClickListener(menuItem -> {
    shareUrl(item.getTitle(), item.getUrl());
    return true;
  });
  menu.show();
}

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

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItem() {
  verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
  itemListener.getValue().onResponse(item);
  adapter.getViewHolder(0).itemView.performLongClick();
  PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
  assertNotNull(popupMenu);
  assertThat(popupMenu.getMenu().findItem(R.id.menu_contextual_vote).isVisible()).isFalse();
  shadowOf(popupMenu).getOnMenuItemClickListener()
      .onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_vote));
  verify(userServices).voteUp(any(Context.class), eq(item.getId()), voteCallback.capture());
}

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

PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
assertNotNull(popupMenu);
assertThat(popupMenu.getMenu().findItem(R.id.menu_contextual_save).isVisible()).isFalse();
shadowOf(popupMenu).getOnMenuItemClickListener()
    .onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_save));

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

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testSelectItemOpenStory() {
  assertThat((View) activity.findViewById(R.id.empty_selection)).isVisible();
  activity.onItemSelected(new TestHnItem(1L) {
    @NonNull
    @Override
    public String getType() {
      return STORY_TYPE;
    }
    @Override
    public String getUrl() {
      return "http://example.com";
    }
  });
  assertThat((View) activity.findViewById(R.id.empty_selection)).isNotVisible();
  assertStoryMode();
  shadowOf(activity).clickMenuItem(R.id.menu_share);
  PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
  assertNotNull(popupMenu);
  assertThat(popupMenu.getMenu()).hasItem(R.id.menu_article).hasItem(R.id.menu_comments);
  shadowOf(activity).clickMenuItem(R.id.menu_external);
  assertNotNull(ShadowPopupMenu.getLatestPopupMenu());
}

代码示例来源:origin: stackoverflow.com

PopupMenu menu = new PopupMenu(getContext(), overflowImageView);
menu.inflate(R.menu.popup);
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { ... });

MenuPopupHelper menuHelper = new MenuPopupHelper(getContext(), (MenuBuilder) menu.getMenu(), overflowImageView);
menuHelper.setForceShowIcon(true);
menuHelper.show();

代码示例来源:origin: Neamar/KISS

PopupMenu popupExcludeMenu = new PopupMenu(context, parentView);
popupExcludeMenu.getMenu().add(EXCLUDE_HISTORY_ID,Menu.NONE, Menu.NONE,R.string.menu_exclude_history);
popupExcludeMenu.getMenu().add(EXCLUDE_KISS_ID,Menu.NONE, Menu.NONE,R.string.menu_exclude_kiss);

相关文章