本文整理了Java中android.widget.PopupMenu
类的一些代码示例,展示了PopupMenu
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PopupMenu
类的具体详情如下:
包路径:android.widget.PopupMenu
类名称:PopupMenu
暂无
代码示例来源:origin: naman14/Timber
@Override
public void onClick(View v) {
final PopupMenu menu = new PopupMenu(mContext, v);
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
menu.inflate(R.menu.popup_playing_queue);
menu.show();
代码示例来源: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: stackoverflow.com
PopupMenu popup = new PopupMenu(getContext(), mImageButton);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.your_menu, popup.getMenu());
代码示例来源: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: TeamNewPipe/NewPipe
public void onPlaybackSpeedClicked() {
if (DEBUG) Log.d(TAG, "onPlaybackSpeedClicked() called");
playbackSpeedPopupMenu.show();
isSomePopupMenuVisible = true;
showControls(DEFAULT_CONTROLS_DURATION);
}
代码示例来源:origin: fire3/sailorcast
public void showTextPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
configurePopupWithTracks(popup, null, DemoPlayer.TYPE_TEXT);
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: stackoverflow.com
PopupMenu popup = new PopupMenu(YourActivity.this,
controlNearDisplayAreaOfMenu);
Menu menu = popup.getMenu();
popup.getMenuInflater().inflate(R.menu.menu_layout_for_popup, menu);
popup.setOnMenuItemClickListener(new OverflowMenuHandler());
代码示例来源:origin: Leaking/WeGit
public void setOverflowMenu(@MenuRes int overflowMenuResId) {
overflow.setVisibility(VISIBLE);
popupMenu = new PopupMenu(context, overflow);
popupMenu.getMenuInflater().inflate(overflowMenuResId, popupMenu.getMenu());
}
代码示例来源: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: 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: robolectric/robolectric
@Implementation
protected void setOnMenuItemClickListener(PopupMenu.OnMenuItemClickListener listener) {
this.onMenuItemClickListener = listener;
directlyOn(realPopupMenu, PopupMenu.class).setOnMenuItemClickListener(listener);
}
代码示例来源:origin: vanilla-music/vanilla
/**
* Opens the OptionsMenu of this view
*/
public void openMenu() {
if (mPopupMenu == null || mParentMenuConsumer == null)
return;
mParentMenuConsumer.onPrepareOptionsMenu(mPopupMenu.getMenu());
mPopupMenu.show();
}
代码示例来源:origin: TeamNewPipe/NewPipe
this.playbackSeekBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY);
this.qualityPopupMenu = new PopupMenu(context, qualityTextView);
this.playbackSpeedPopupMenu = new PopupMenu(context, playbackSpeedTextView);
this.captionPopupMenu = new PopupMenu(context, captionTextView);
代码示例来源: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: robolectric/robolectric
@Test
public void testIsShowing_returnsFalseIfShownThenDismissed() throws Exception {
popupMenu.show();
popupMenu.dismiss();
assertThat(shadowPopupMenu.isShowing()).isFalse();
}
代码示例来源: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 -> {
});
captionPopupMenu.setOnDismissListener(this);
代码示例来源:origin: stackoverflow.com
PopupMenu popup = new PopupMenu(getContext(), mImageButton);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(......);
代码示例来源:origin: hidroh/materialistic
@SuppressLint("NewApi")
@Override
public PopupMenu inflate(@MenuRes int menuRes) {
popupMenu.inflate(menuRes);
return this;
}
代码示例来源:origin: TeamNewPipe/NewPipe
private void onCaptionClicked() {
if (DEBUG) Log.d(TAG, "onCaptionClicked() called");
captionPopupMenu.show();
isSomePopupMenuVisible = true;
showControls(DEFAULT_CONTROLS_DURATION);
}
内容来源于网络,如有侵权,请联系作者删除!