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

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

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

PopupMenu.inflate介绍

暂无

代码示例

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

private PopupMenu buildPopup(final View button) {
    PopupMenu popup = new PopupMenu(mContext, button);
    popup.inflate(R.menu.mission);
    popup.setOnMenuItemClickListener(option -> handlePopupItem(this, option));
    return popup;
  }
}

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

@SuppressLint("NewApi")
@Override
public PopupMenu inflate(@MenuRes int menuRes) {
  popupMenu.inflate(menuRes);
  return this;
}

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

menu.inflate(R.menu.popup_song);

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

menu.inflate(R.menu.popup_song);
menu.show();
if (isPlaylist)

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

menu.inflate(R.menu.popup_playing_queue);
menu.show();

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

menu.inflate(R.menu.popup_song);
menu.show();

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

menu.inflate(R.menu.popup_song);
menu.show();

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

menu.inflate(R.menu.popup_song);
menu.show();

代码示例来源: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: julian-klode/dns66

@Override
public void onClick(View v) {
  PopupMenu menu = new PopupMenu(getContext(), rootView.findViewById(R.id.change_default));
  menu.inflate(R.menu.whitelist_popup);
  menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
    @Override

代码示例来源:origin: ftctechnh/ftc_app

@Override
 public void onClick(View v) {
  PopupMenu popupMenu = new PopupMenu(FtcRobotControllerActivity.this, v);
  popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
   @Override
   public boolean onMenuItemClick(MenuItem item) {
    return onOptionsItemSelected(item); // Delegate to the handler for the hardware menu button
   }
  });
  popupMenu.inflate(R.menu.ftc_robot_controller);
  popupMenu.show();
 }
});

代码示例来源:origin: xbmc/Kore

@OnClick(R.id.overflow)
public void onOverflowClicked(View v) {
  PopupMenu popup = new PopupMenu(getActivity(), v);
  popup.inflate(R.menu.video_overflow);
  popup.setOnMenuItemClickListener(overflowMenuClickListener);
  popup.show();
}

代码示例来源:origin: DF1E/SimpleExplorer

private void showMenu(View v) {
  PopupMenu popup = new PopupMenu(mActivity, v);
  // This activity implements OnMenuItemClickListener
  popup.setOnMenuItemClickListener(this);
  popup.inflate(R.menu.fab_menu);
  popup.show();
}

代码示例来源:origin: geniusgithub/AndroidDialer

/**
 * Called by the containing Activity to tell this Fragment to build an overflow options
 * menu for display by the container when appropriate.
 *
 * @param invoker the View that invoked the options menu, to act as an anchor location.
 */
private PopupMenu buildOptionsMenu(View invoker) {
  final PopupMenu popupMenu = new PopupMenu(getActivity(), invoker) {
    @Override
    public void show() {
      final Menu menu = getMenu();
      boolean enable = !isDigitsEmpty();
      for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        item.setEnabled(enable);
        if (item.getItemId() == R.id.menu_call_with_note) {
          item.setVisible(CallUtil.isCallWithSubjectSupported(getContext()));
        }
      }
      super.show();
    }
  };
  popupMenu.inflate(R.menu.dialpad_options);
  popupMenu.setOnMenuItemClickListener(this);
  return popupMenu;
}

代码示例来源:origin: cemrich/zapp

@Override
public void onShowLongClicked(MediathekShow show, View view) {
  this.longClickShow = show;
  PopupMenu menu = new PopupMenu(getContext(), view, Gravity.TOP | Gravity.END);
  menu.inflate(R.menu.activity_mediathek_detail);
  menu.show();
  menu.setOnMenuItemClickListener(this::onContextMenuItemClicked);
}

代码示例来源:origin: cemrich/zapp

@Override
public void onItemLongClick(ChannelModel channel, View view) {
  this.longClickChannel = channel;
  PopupMenu menu = new PopupMenu(getContext(), view, Gravity.TOP | Gravity.END);
  menu.inflate(R.menu.activity_channel_list_context);
  menu.show();
  menu.setOnMenuItemClickListener(this::onContextMenuItemClicked);
}

代码示例来源:origin: brainysoon/cyberCar

@Override
  public void onClick(View v) {
    final PopupMenu menu = new PopupMenu(mContext, v);
    menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
      @Override
      public boolean onMenuItemClick(MenuItem item) {
        switch (item.getItemId()) {
          case R.id.popup_song_play:
            MusicPlayer.playAll(mContext, getSongIds(), position, -1, TimberUtils.IdType.NA, false);
            break;
          case R.id.popup_song_goto_album:
            NavigationUtils.goToAlbum(mContext, arraylist.get(position).albumId);
            break;
          case R.id.popup_song_goto_artist:
            NavigationUtils.goToArtist(mContext, arraylist.get(position).artistId);
            break;
          case R.id.popup_song_addto_playlist:
            AddPlaylistDialog.newInstance(arraylist.get(position)).show(((AppCompatActivity) mContext).getSupportFragmentManager(), "ADD_PLAYLIST");
            break;
        }
        return false;
      }
    });
    menu.inflate(R.menu.popup_playing_queue);
    menu.show();
  }
});

代码示例来源:origin: ymback/NGA-CLIENT-VER-OPEN-SOURCE

@Override
public void onClick(View view) {
  mMenuItemClickListener.setThreadRowInfo((ThreadRowInfo) view.getTag());
  int menuId;
  if (mRequestParam.pid == 0) {
    menuId = R.menu.article_list_context_menu;
  } else {
    menuId = R.menu.article_list_context_menu_with_tid;
  }
  PopupMenu popupMenu = new PopupMenu(getContext(), view);
  popupMenu.inflate(menuId);
  onPrepareOptionsMenu(popupMenu.getMenu(), (ThreadRowInfo) view.getTag());
  popupMenu.show();
  popupMenu.setOnMenuItemClickListener(mMenuItemClickListener);
}

代码示例来源:origin: rohanoid5/Muzesto

@Override
  public void onClick(View v) {
    final PopupMenu menu = new PopupMenu(mContext, v);
    menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
      @Override
      public boolean onMenuItemClick(MenuItem item) {
        switch (item.getItemId()) {
          case R.id.popup_song_play:
            MusicPlayer.playAll(mContext, getSongIds(), position, -1, TimberUtils.IdType.NA, false);
            break;
          case R.id.popup_song_goto_album:
            NavigationUtils.goToAlbum(mContext, arraylist.get(position).albumId);
            break;
          case R.id.popup_song_goto_artist:
            NavigationUtils.goToArtist(mContext, arraylist.get(position).artistId);
            break;
          case R.id.popup_song_addto_playlist:
            AddPlaylistDialog.newInstance(arraylist.get(position)).show(((AppCompatActivity) mContext).getSupportFragmentManager(), "ADD_PLAYLIST");
            break;
        }
        return false;
      }
    });
    menu.inflate(R.menu.popup_playing_queue);
    menu.show();
  }
});

代码示例来源:origin: OceanLabs/Android-Print-SDK

/*****************************************************
 *
 * If there are multiple image sources - displays a pop-up
 * menu to add an image.
 *
 * If there is just one image image - launches the picker
 * directly.
 *
 *****************************************************/
protected PopupMenu onAddImage( View view )
 {
 if ( checkDisplayMultipleImageSources( true ) )
  {
  PopupMenu popupMenu = new PopupMenu( mKiteActivity, view );
  popupMenu.inflate( R.menu.add_image_popup );
  addImageSourceMenuItems( popupMenu.getMenu() );
  popupMenu.setOnMenuItemClickListener( this );
  popupMenu.show();
  return ( popupMenu );
  }
 return ( null );
 }

相关文章