本文整理了Java中android.view.Menu.add()
方法的一些代码示例,展示了Menu.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Menu.add()
方法的具体详情如下:
包路径:android.view.Menu
类名称:Menu
方法名:add
暂无
代码示例来源:origin: 4thline/cling
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 0, 0, R.string.switchRouter).setIcon(android.R.drawable.ic_menu_revert);
menu.add(0, 1, 0, R.string.toggleDebugLogging).setIcon(android.R.drawable.ic_menu_info_details);
return true;
}
代码示例来源:origin: 4thline/cling
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 0, 0, R.string.searchLAN).setIcon(android.R.drawable.ic_menu_search);
// DOC:OPTIONAL
menu.add(0, 1, 0, R.string.switchRouter).setIcon(android.R.drawable.ic_menu_revert);
menu.add(0, 2, 0, R.string.toggleDebugLogging).setIcon(android.R.drawable.ic_menu_info_details);
// DOC:OPTIONAL
return true;
}
代码示例来源:origin: rmtheis/android-ocr
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// MenuInflater inflater = getMenuInflater();
// inflater.inflate(R.menu.options_menu, menu);
super.onCreateOptionsMenu(menu);
menu.add(0, SETTINGS_ID, 0, "Settings").setIcon(android.R.drawable.ic_menu_preferences);
menu.add(0, ABOUT_ID, 0, "About").setIcon(android.R.drawable.ic_menu_info_details);
return true;
}
代码示例来源:origin: facebook/facebook-android-sdk
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// only add the menu when the selection fragment is showing
if (fragments[RPS].isVisible()) {
if (menu.size() == 0) {
share = menu.add(R.string.share_on_facebook);
message = menu.add(R.string.send_with_messenger);
challenge = menu.add(R.string.challenge_friends);
settings = menu.add(R.string.check_settings);
}
return true;
} else {
menu.clear();
settings = null;
}
return false;
}
代码示例来源:origin: graphhopper/graphhopper
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, NEW_MENU_ID, 0, "Google");
// menu.add(0, NEW_MENU_ID + 1, 0, "Other");
return true;
}
代码示例来源:origin: alexvasilkov/GestureViews
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (infoTextId != 0) {
MenuItem item = menu.add(Menu.NONE, R.id.menu_info, Menu.NONE, R.string.menu_info);
item.setIcon(R.drawable.ic_info_outline_white_24dp);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
return true;
}
代码示例来源:origin: square/leakcanary
@Override public boolean onCreateOptionsMenu(Menu menu) {
AnalyzedHeap visibleLeak = getVisibleLeak();
if (visibleLeak != null) {
menu.add(R.string.leak_canary_share_leak)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override public boolean onMenuItemClick(MenuItem item) {
shareLeak();
return true;
}
});
if (visibleLeak.heapDumpFileExists) {
menu.add(R.string.leak_canary_share_heap_dump)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override public boolean onMenuItemClick(MenuItem item) {
shareHeapDump();
return true;
}
});
}
return true;
}
return false;
}
代码示例来源:origin: termux/termux-app
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
int show = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
menu.add(Menu.NONE, 1, Menu.NONE, R.string.copy_text).setShowAsAction(show);
menu.add(Menu.NONE, 2, Menu.NONE, R.string.paste_text).setEnabled(clipboard.hasPrimaryClip()).setShowAsAction(show);
menu.add(Menu.NONE, 3, Menu.NONE, R.string.text_selection_more);
return true;
}
代码示例来源:origin: mmin18/RealtimeBlurView
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add("Popup").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add("List").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: north2016/T-MVP
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
if (collapsedMenu != null && !appBarExpanded)
collapsedMenu.add("Add").setIcon(R.drawable.ic_menu_send).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
return super.onPrepareOptionsMenu(collapsedMenu);
}
}
代码示例来源:origin: alexvasilkov/GestureViews
private void addBoolMenu(Menu menu, boolean checked, @StringRes int titleId) {
MenuItem item = menu.add(Menu.NONE, titleId, 0, titleId);
item.setCheckable(true);
item.setChecked(checked);
}
代码示例来源:origin: markzhai/AndroidPerformanceMonitor
@Override
public boolean onCreateOptionsMenu(Menu menu) {
final BlockInfoEx blockInfo = getBlock(mBlockStartTime);
if (blockInfo != null) {
menu.add(R.string.block_canary_share_leak)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
shareBlock(blockInfo);
return true;
}
});
menu.add(R.string.block_canary_share_stack_dump)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
shareHeapDump(blockInfo);
return true;
}
});
return true;
}
return false;
}
代码示例来源:origin: robolectric/robolectric
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add("Algebraic!");
return true;
}
}
代码示例来源:origin: alexvasilkov/GestureViews
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
if (resultView.getVisibility() != View.VISIBLE) {
MenuItem crop = menu.add(Menu.NONE, R.id.menu_crop, 0, R.string.menu_crop);
crop.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
crop.setIcon(R.drawable.ic_check_white_24dp);
}
return true;
}
代码示例来源:origin: square/sqlbrite
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
MenuItem item = menu.add(R.string.new_list)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override public boolean onMenuItemClick(MenuItem item) {
listener.onNewListClicked();
return true;
}
});
MenuItemCompat.setShowAsAction(item, SHOW_AS_ACTION_IF_ROOM | SHOW_AS_ACTION_WITH_TEXT);
}
代码示例来源:origin: square/sqlbrite
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
MenuItem item = menu.add(R.string.new_item)
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override public boolean onMenuItemClick(MenuItem item) {
listener.onNewItemClicked(getListId());
return true;
}
});
MenuItemCompat.setShowAsAction(item, SHOW_AS_ACTION_IF_ROOM | SHOW_AS_ACTION_WITH_TEXT);
}
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
final MenuItem restoreItem = menu.add(Menu.NONE, MENU_ITEM_RESTORE_ID, Menu.NONE, R.string.restore_defaults);
restoreItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
final int restoreIcon = ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_restore_defaults);
restoreItem.setIcon(AppCompatResources.getDrawable(requireContext(), restoreIcon));
}
代码示例来源: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: TeamNewPipe/NewPipe
private void showServices() {
serviceArrow.setImageResource(R.drawable.ic_arrow_up_white);
for(StreamingService s : NewPipe.getServices()) {
final String title = s.getServiceInfo().getName() +
(ServiceHelper.isBeta(s) ? " (beta)" : "");
drawerItems.getMenu()
.add(R.id.menu_services_group, s.getServiceId(), ORDER, title)
.setIcon(ServiceHelper.getIcon(s.getServiceId()));
}
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(true);
}
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!