List of usage examples for android.view MenuItem getMenuInfo
public ContextMenuInfo getMenuInfo();
From source file:com.vuze.android.remote.activity.IntentHandler.java
@Override public boolean onContextItemSelected(MenuItem menuitem) { ContextMenuInfo menuInfo = menuitem.getMenuInfo(); AdapterContextMenuInfo adapterMenuInfo = (AdapterContextMenuInfo) menuInfo; Object item = listview.getItemAtPosition(adapterMenuInfo.position); if (!(item instanceof RemoteProfile)) { return super.onContextItemSelected(menuitem); }//from w w w . ja v a 2s . c o m final RemoteProfile remoteProfile = (RemoteProfile) item; int itemId = menuitem.getItemId(); if (itemId == R.id.action_edit_pref) { editProfile(remoteProfile); return true; } else if (itemId == R.id.action_delete_pref) { new AlertDialog.Builder(this).setTitle("Remove Profile?") .setMessage( "Configuration settings for profile '" + remoteProfile.getNick() + "' will be deleted.") .setPositiveButton("Remove", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { appPreferences.removeRemoteProfile(remoteProfile.getID()); adapter.refreshList(); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).setIcon(android.R.drawable.ic_dialog_alert).show(); return true; } return super.onContextItemSelected(menuitem); }
From source file:net.potterpcs.recipebook.IngredientsEditor.java
@Override public boolean onContextItemSelected(MenuItem item) { // The Ingredients editor has no "Move Up"/"Move Down" options, // because the list of ingredients is unordered, unlike directions, // which must come in a specific order. AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.ctxdeleteingredient: // "Delete" option adapter.remove(adapter.getItem(info.position)); currentIngredient = -1;/*from ww w .j ava2 s. c om*/ return true; case R.id.ctxeditingredient: // "Edit" option String selected = adapter.getItem(info.position); currentIngredient = info.position; // replace the editbox text EditText edit = ((EditText) getView().findViewById(R.id.ingredientsedit)); edit.setText(selected); edit.requestFocus(); // put a placeholder in the list adapter.remove(selected); adapter.insert(getResources().getString(R.string.recipereplacetext), currentIngredient); return true; default: return super.onContextItemSelected(item); } }
From source file:com.ame.armymax.SearchActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { int itemId = item.getItemId(); AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) item.getMenuInfo(); resultList.remove(aInfo.position);// w w w . j a v a2 s .co m adapter.notifyDataSetChanged(); return true; }
From source file:org.melato.bus.android.activity.SequenceActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); boolean handled = false; switch (item.getItemId()) { case R.id.open: open(info.position);/*ww w.ja v a 2 s . c o m*/ handled = true; break; case R.id.remove: removeLeg(info.position); handled = true; break; case R.id.wait_time: editWaitTime(info.position); handled = true; break; default: break; } return handled; }
From source file:org.opensourcetlapp.tl.ShowForumList.java
public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.hide: AdapterView.AdapterContextMenuInfo info; try {/*from w w w.j av a2 s. com*/ info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); } catch (ClassCastException e) { Log.e(TAG, "bad menuInfo", e); return false; } db.hideForum(getListAdapter().getItemId(info.position)); doThreadStuff(); break; } return true; }
From source file:com.codebutler.farebot.fragment.CardsFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { if (item.getItemId() == R.id.delete_card) { int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position; SavedCard savedCard = (SavedCard) getListView().getItemAtPosition(position); mCardPersister.deleteCard(savedCard); getLoaderManager().restartLoader(0, null, mLoaderCallbacks); return true; }// ww w. jav a2 s . co m return false; }
From source file:org.peercast.core.PeerCastFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { PeerCastServiceController controller = getActivity2().getPeerCastServiceController(); ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) item .getMenuInfo();/*from w ww .j a va 2 s . co m*/ int type = ExpandableListView.getPackedPositionType(info.packedPosition); int gPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); int cPos = ExpandableListView.getPackedPositionChild(info.packedPosition); Channel ch = (Channel) mListAdapter.getGroup(gPos); switch (item.getItemId()) { case R.id.menu_ch_disconnect: Log.i(TAG, "Disconnect channel: " + ch); controller.disconnectChannel(ch.getChannel_ID()); return true; case R.id.menu_ch_keep: Log.i(TAG, "Keep channel: " + ch); controller.setChannelKeep(ch.getChannel_ID(), !item.isChecked()); return true; case R.id.menu_ch_play: Uri u = getStreamUri(ch); Intent intent = new Intent(Intent.ACTION_VIEW, u); try { showToast(u.toString()); startActivity(intent); } catch (ActivityNotFoundException e) { getActivity2().showAlertDialog(R.string.t_error, e.getLocalizedMessage(), false); } return true; case R.id.menu_ch_bump: Log.i(TAG, "Bump channel: " + ch); controller.bumpChannel(ch.getChannel_ID()); return true; case R.id.menu_svt_disconnect: // Servent svt = (Servent) mListAdapter.getChild(gPos, cPos); Log.i(TAG, "Disconnect servent: " + svt); controller.disconnectServent(svt.getServent_ID()); return true; default: return super.onContextItemSelected(item); } }
From source file:com.simplaapliko.wakeup.sample.ui.MainActivityFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case CONTEXT_MENU_DELETE: AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); long id = info.id; Alarm alarm = new AlarmDAO(getContext()).selectById(id); new AlarmController().cancelAlarm(getContext(), alarm); restartLoader();// w ww. ja va 2 s . co m return true; default: return super.onContextItemSelected(item); } }
From source file:net.sourceforge.servestream.fragment.AlarmClockFragment.java
@Override public boolean onContextItemSelected(final android.view.MenuItem item) { final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); final int id = (int) info.id; // Error check just in case. if (id == -1) { return super.onContextItemSelected(item); }// ww w. ja va 2s . c om switch (item.getItemId()) { case R.id.delete_alarm: // Confirm that the alarm will be deleted. new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.delete_alarm)) .setMessage(getString(R.string.alarm_delete_confirmation_msg)) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int w) { Alarms.deleteAlarm(getActivity(), id); } }).setNegativeButton(android.R.string.cancel, null).show(); return true; case R.id.enable_alarm: final Cursor c = (Cursor) mAlarmsList.getAdapter().getItem(info.position); final Alarm alarm = new Alarm(c); Alarms.enableAlarm(getActivity(), alarm.id, !alarm.enabled); if (!alarm.enabled) { popAlarmSetToast(getActivity(), alarm.hour, alarm.minutes, alarm.daysOfWeek); } return true; case R.id.edit_alarm: Intent intent = new Intent(getActivity(), SetAlarmActivity.class); intent.putExtra(Alarms.ALARM_ID, id); startActivity(intent); return true; default: break; } return super.onContextItemSelected(item); }
From source file:com.rvl.android.getnzb.LocalNZB.java
public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); String localFileList[] = fileList(); switch (item.getItemId()) { case R.id.deleteLocalFile: deleteLocalFileContextItem(info.id); return true; case R.id.uploadLocalFileHellaNZB: uploadLocalFileHellaNZB(localFileList[(int) info.id]); return true; case R.id.uploadLocalFileFTP: uploadLocalFileFTP(localFileList[(int) info.id]); return true; /*case R.id.uploadLocalFileDropbox: uploadLocalFileDropbox(localFileList[(int) info.id]); return true;//from www . j a v a2s .c o m */ } return false; }