List of usage examples for android.view MenuItem getMenuInfo
public ContextMenuInfo getMenuInfo();
From source file:it.sineo.android.tileMapEditor.HomeActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.home_ctx_menu_delete: { AdapterContextMenuInfo cmi = (AdapterContextMenuInfo) item.getMenuInfo(); Uri mapUri = Uri.withAppendedPath(C.CONTENT_URI, Long.toString(cmi.id)); getContentResolver().delete(mapUri, null, null); return true; }//from w w w .j a va 2s .c o m default: return super.onContextItemSelected(item); } }
From source file:eu.thecoder4.gpl.pleftdroid.PleftDroidActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case DELETE_ID: final long aid; aid = info.id;// w w w. ja v a 2 s .co m new AlertDialog.Builder(this).setTitle(R.string.dialog_title_deleteappt) .setMessage(R.string.dialog_msg_deleteappt) .setPositiveButton(android.R.string.ok, new OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { // Proceed and delete this mDbAdapter.open(); mDbAdapter.deleteAppointment(aid); mDbAdapter.close(); fillList(); } }).setNegativeButton(android.R.string.cancel, new OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { // Do nothing } }).show(); return true; } return super.onContextItemSelected(item); }
From source file:bander.notepad.NoteListAppCompat.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info; try {//from w w w .ja v a 2 s . com info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); } catch (ClassCastException e) { return false; } switch (item.getItemId()) { case DELETE_ID: deleteNote(this, info.id); return true; case SEND_ID: Uri uri = ContentUris.withAppendedId(Note.CONTENT_URI, info.id); Cursor cursor = getContentResolver().query(uri, new String[] { Note._ID, Note.TITLE, Note.BODY }, null, null, null); Note note = Note.fromCursor(cursor); cursor.close(); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, note.getBody()); startActivity(Intent.createChooser(intent, getString(R.string.menu_send))); return true; } return false; }
From source file:com.orangelabs.rcs.ri.messaging.filetransfer.FileTransferList.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); Cursor cursor = (Cursor) (mAdapter.getItem(info.position)); String transferId = cursor.getString(cursor.getColumnIndexOrThrow(FileTransferLog.FT_ID)); try {// w w w . j a v a 2s .com switch (item.getItemId()) { case MENU_ITEM_RESEND: if (LogUtils.isActive) { Log.d(LOGTAG, "onContextItemSelected resend ftId=".concat(transferId)); } if (!isServiceConnected(RcsServiceName.FILE_TRANSFER)) { showMessage(R.string.label_service_not_available); return true; } FileTransfer transfer = mFileTransferService.getFileTransfer(transferId); if (transfer != null) { transfer.resendTransfer(); } return true; case MENU_ITEM_DELETE: if (LogUtils.isActive) { Log.d(LOGTAG, "onContextItemSelected delete ftId=".concat(transferId)); } if (!isServiceConnected(RcsServiceName.FILE_TRANSFER)) { showMessage(R.string.label_service_not_available); return true; } mFileTransferService.deleteFileTransfer(transferId); return true; } } catch (RcsServiceException e) { showExceptionThenExit(e); } return super.onContextItemSelected(item); }
From source file:com.wikaba.ogapp.NoAccountFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.remove) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); int rowPosition = info.position; AccountCredentials creds = allAccounts.get(rowPosition); DatabaseManager dbmanager = new DatabaseManager(act); dbmanager.removeAccount(creds.universe, creds.username); dbmanager.close();/*from w w w .j a v a 2 s . c om*/ allAccounts.remove(rowPosition); AccountAdapter adapter = (AccountAdapter) existingAccs.getAdapter(); adapter.notifyDataSetChanged(); return true; } return super.onContextItemSelected(item); }
From source file:piuk.blockchain.android.ui.WalletTransactionsFragment.java
@Override public boolean onContextItemSelected(final MenuItem item) { final AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo(); final ListAdapter adapter = ((ListView) lastContextMenuView).getAdapter(); final MyTransaction tx = (MyTransaction) adapter.getItem(menuInfo.position); switch (item.getItemId()) { case R.id.wallet_transactions_context_edit_address: editAddress(tx);//ww w . j a va2 s . co m return true; default: return false; } }
From source file:org.restcomm.android.olympus.MainFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); HashMap<String, String> contact = (HashMap) contactList.get(info.position); if (item.getTitle().toString().equals("Update Contact")) { mCallbacks.onContactUpdate(contact, AddUserDialogFragment.DIALOG_TYPE_UPDATE_CONTACT); }//from w ww . j av a2 s. c o m if (item.getTitle().toString().equals("Remove Contact")) { contactsController.removeContact(contactList, contact.get(CONTACT_KEY), contact.get(CONTACT_VALUE)); this.listViewAdapter.notifyDataSetChanged(); } return true; }
From source file:com.mongolduu.android.ng.ChartFragment.java
public boolean onContextItemSelected(MenuItem item) { if (item.getGroupId() != fragmentIndex) { return false; }/*from www .j av a 2 s.co m*/ AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); SongInfo songinfo = (SongInfo) listview.getAdapter().getItem(menuInfo.position); switch (item.getItemId()) { case R.id.context_menu_remove_song_from_device: deleteSong(songinfo); break; case R.id.context_menu_download: downloadSong(songinfo); break; case R.id.context_menu_play_song: playSong(songinfo); break; case R.id.context_menu_set_as_ringtone: setSongAsRingtone(songinfo); break; default: return super.onContextItemSelected(item); } return true; }
From source file:cz.maresmar.sfm.view.user.UserListActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.user_edit: long itemId = info.id; Uri userUri = ContentUris.withAppendedId(ProviderContract.User.getUri(), itemId); return true; case R.id.user_delete: // remove stuff here return true; default:/*from w w w . j a va 2 s .co m*/ return super.onContextItemSelected(item); } }
From source file:net.vivekiyer.GAL.CorporateContactRecordFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); // Get the selected item from the listview adapter final KeyValuePair kvp = m_adapter.getItem(info.position); switch (item.getItemId()) { case MENU_ID_CALL: Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" //$NON-NLS-1$ + kvp.getValue()));/*from w ww .j a va 2 s .c om*/ startActivity(intent); break; case MENU_ID_SMS: intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" //$NON-NLS-1$ + kvp.getValue())); startActivity(intent); break; case MENU_ID_COPY_TO_CLIPBOARD: final ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(kvp.getValue()); Toast.makeText(this.getActivity(), getString(R.string.text_copied_to_clipboard), Toast.LENGTH_SHORT) .show(); break; case MENU_ID_EDIT_BEFORE_CALL: intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" //$NON-NLS-1$ + kvp.getValue())); startActivity(intent); break; case MENU_ID_EMAIL: intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); //$NON-NLS-1$ intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { kvp.getValue() }); startActivity(Intent.createChooser(intent, getString(R.string.send_mail))); break; default: return super.onContextItemSelected(item); } return true; }