private void addOnClickListener() { contactList.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { view.showContextMenu(); } }) }
@Override public boolean onKeyDown(int keycode, @NonNull KeyEvent e) { if (keycode == KeyEvent.KEYCODE_MENU) { // For devices with a physical menu button, we still want to display *our* contextual menu menuButton.showContextMenu(); menuButton.performHapticFeedback(LONG_PRESS); return true; } return super.onKeyDown(keycode, e); }
/** * Display menu, on short or long press. * * @param menuButton "kebab" menu (3 dots) */ public void onMenuButtonClicked(View menuButton) { // When the kiss bar is displayed, the button can still be clicked in a few areas (due to favorite margin) // To fix this, we discard any click event occurring when the kissbar is displayed if (!isViewingSearchResults()) { return; } if (!forwarderManager.onMenuButtonClicked(this.menuButton)) { this.menuButton.showContextMenu(); this.menuButton.performHapticFeedback(LONG_PRESS); } }
@Override public void onItemClick(ListAdapter adapter, View view, int position) { Object adapterItem = adapter.getItem(position); if (adapterItem instanceof TagsMenu.MenuItemTag) { TagsMenu.MenuItemTag item = (TagsMenu.MenuItemTag) adapterItem; // show only apps that match this tag mainActivity.showMatchingTags(item.tag); } else if (adapterItem instanceof TagsMenu.MenuItemBtn) { switch (((TagsMenu.MenuItemBtn) adapterItem).nameRes) { case R.string.ctx_menu: if (popupMenu != null) popupMenu.dismiss(); popupMenu = null; anchor.showContextMenu(); break; case R.string.show_history: mainActivity.showHistory(); break; case R.string.show_untagged: mainActivity.showUntagged(); break; } } } });
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { if(isChecked){ View v = buttonView.getParent(); // get the parent row view containing the checkbox v.showContextMenu(); // show the context menu } } }
@Override public boolean onLongClick(View v) { Log.d("Debug", "OnLongClick"); v.showContextMenu(); return true; }
@Override public boolean onLongClick(final View view) { view.showContextMenu(); return true; }
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, final View componente, int pos, long id){ String title = data.get(pos).get("titolo"); String thumbimage = data.get(pos).get("thumbnail"); registerForContextMenu(componente); componente.showContextMenu(); } });
onListItemClick(ListView l, View v, int position, long id) { v.showContextMenu(); }
@Override public void ItemLongClicked(View v, EventItem eventItem) { mCurrentEventItem = eventItem; v.showContextMenu(); } });
spinner.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int arg2, long arg3) { view.showContextMenu(); return true; } });
private class selectOnLongClickListener implements View.OnLongClickListener{ private ViewHolder mViewHolder; private selectOnLongClickListener(ViewHolder viewHolder) { mViewHolder = viewHolder; } @Override public boolean onLongClick(View v) { Log.d("Debug", "OnLongClick"); v.showContextMenu(); return true; } }
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { String id = view.getId().toString(); //open context menu now view.showContextMenu(); }
btn_settings = (ImageButton) findViewById(R.id.btn_settings); registerForContextMenu(btn_settings); btn_settings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { view.showContextMenu(); } });
@Override public void onClick(View v) { if (!MyPreferences.isLongPressToOpenContextMenu() && v.getParent() != null) { v.showContextMenu(); } }
@Override public void onClick(final View view, int position, MotionEvent e) { View menuButton = view.findViewById(R.id.menu); if (isViewClicked(e, menuButton)) { menuButton.setOnCreateContextMenuListener(this); menuButton.showContextMenu(); return; } ... }
@Override public void onClick(View v) { if (!MyPreferences.isLongPressToOpenContextMenu() && v.getParent() != null) { v.showContextMenu(); } }
private void setOnButtonClick(final View viewGroup, int buttonId, final NoteContextMenuItem menuItem) { (buttonId == 0 ? viewGroup : viewGroup.findViewById(buttonId)).setOnClickListener( v -> { if (menuItem.equals(NoteContextMenuItem.UNKNOWN)) { viewGroup.showContextMenu(); } else { onButtonClick(v, menuItem); } } ); }
public static void openOptionsMenu(final AppCompatActivity activity, final View view) { if (activity.getSupportActionBar().isShowing()) { activity.getSupportActionBar().openOptionsMenu(); } else { view.showContextMenu(); } }
/** * Starts showing a context menu for {@code view} based on {@code params}. * @param contentViewCore The {@link ContentViewCore} to show the menu to. * @param params The {@link ContextMenuParams} that indicate what menu items to show. */ @CalledByNative private boolean showContextMenu(ContentViewCore contentViewCore, ContextMenuParams params) { final View view = contentViewCore.getContainerView(); if (view == null || view.getVisibility() != View.VISIBLE || view.getParent() == null) { return false; } mCurrentContextMenuParams = params; view.setOnCreateContextMenuListener(this); if (view.showContextMenu()) { WebContents webContents = contentViewCore.getWebContents(); RecordHistogram.recordBooleanHistogram( "ContextMenu.Shown", webContents != null); if (webContents != null) webContents.onContextMenuOpened(); return true; } return false; }