public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.popupmenu, menu); menu.setHeaderTitle("Near2Me").setHeaderIcon(R.drawable.near2me); menu.getItem(0).setTitle("Mapa").setIcon(R.drawable.map); menu.getItem(1).setTitle("Listado").setIcon(R.drawable.lista); menu.getItem(2).setTitle("Configuraciones").setIcon(R.drawable.settings32x32); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { MenuInflater inflater = mCoolReader.getMenuInflater(); menu.clear(); inflater.inflate( mList.isShortcutMode() ? R.menu.cr3_bookmark_shortcut_context_menu : R.menu.cr3_bookmark_context_menu, menu); AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo; if (mi != null) selectedItem = mi.position; Bookmark bm = mList.getSelectedBookmark(); menu.setHeaderTitle(getContext().getString(R.string.context_menu_title_bookmark)); for (int i = 0; i < menu.size(); i++) { MenuItem menuItem = menu.getItem(i); if (menuItem.getItemId() == R.id.bookmark_shortcut_goto || menuItem.getItemId() == R.id.bookmark_edit || menuItem.getItemId() == R.id.bookmark_delete) menuItem.setEnabled(bm != null); if (menuItem.getItemId() == R.id.bookmark_edit) menuItem.setEnabled( bm != null && (bm.getType() == Bookmark.TYPE_COMMENT || bm.getType() == Bookmark.TYPE_CORRECTION)); menuItem.setOnMenuItemClickListener( new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { onContextItemSelected(item); return true; } }); } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (!shouldShowMenu(mCurrentContextMenuParams)) return; assert mPopulator != null; mPopulator.buildContextMenu(menu, v.getContext(), mCurrentContextMenuParams); for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setOnMenuItemClickListener(this); } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle(R.string.edit_text); menu.add(0, SELECT_TEXT_ID, 0, R.string.select_text); menu.add(0, COPY_ALL_ID, 0, R.string.copy_all); menu.add(0, PASTE_ID, 0, R.string.paste); menu.add(0, SEND_CONTROL_KEY_ID, 0, R.string.send_control_key); menu.add(0, SEND_FN_KEY_ID, 0, R.string.send_fn_key); if (!canPaste()) { menu.getItem(PASTE_ID).setEnabled(false); } }
@Override public void onCreateContextMenu(ContextMenu menu) { MenuHandler handler = new MenuHandler(); if (mMenuItemsStrings == null) { Resources resources = getResources(); mMenuItemsStrings = new String[3]; mMenuItemsStrings[CUT] = resources.getString(android.R.string.cut); mMenuItemsStrings[COPY] = resources.getString(android.R.string.copy); mMenuItemsStrings[PASTE] = resources.getString(android.R.string.paste); } for (int i = 0; i < mMenuItemsStrings.length; i++) { menu.add(Menu.NONE, i, i, mMenuItemsStrings[i]).setOnMenuItemClickListener(handler); } if (getText().length() == 0) { menu.getItem(CUT).setVisible(false); menu.getItem(COPY).setVisible(false); } ClipData primaryClip = getPrimaryClip(); if (primaryClip == null || primaryClip.getItemCount() == 0 || !canPaste(primaryClip.getItemAt(0).coerceToText(getContext()))) { menu.getItem(PASTE).setVisible(false); } }
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo info; try { info = (AdapterView.AdapterContextMenuInfo) menuInfo; } catch (ClassCastException e) { LOG.error("Could not cast [{}] to [{}].", menuInfo, AdapterView.AdapterContextMenuInfo.class); return; } Cursor cursor = (Cursor) getListAdapter().getItem(info.position); if (cursor == null) { LOG.error("The cursor is not available from the list adapter."); return; } MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.split_marker_set_list_item_menu, menu); String splitMarkerSetName = cursor.getString(cursor.getColumnIndex(TrackLoggerData.SplitMarkerSet.COLUMN_NAME_NAME)); menu.setHeaderTitle(splitMarkerSetName); for (int i = 0; i < menu.size(); i++) { MenuItem menuItem = menu.getItem(i); switch (menuItem.getItemId()) { case R.id.split_marker_set_list_item_menu_delete: try { info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo(); if (isInUse((int) info.id)) { menuItem.setEnabled(false); } } catch (ClassCastException e) { LOG.error( "Could not cast [{}] to [{}].", menuItem.getMenuInfo(), AdapterView.AdapterContextMenuInfo.class); menuItem.setEnabled(false); } } } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { MenuInflater inflater = mCoolReader.getMenuInflater(); inflater.inflate(R.menu.cr3_bookmark_shortcut_context_menu, menu); AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo; if (mi != null) selectedItem = mi.position; menu.setHeaderTitle(getContext().getString(R.string.context_menu_title_bookmark)); for (int i = 0; i < menu.size(); i++) { menu.getItem(i) .setOnMenuItemClickListener( new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { onContextItemSelected(item); return true; } }); } }