List of usage examples for android.view ContextMenu findItem
public MenuItem findItem(int id);
From source file:org.catrobat.catroid.ui.fragment.FormulaEditorDataFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { if (!inContextMode) { super.onCreateContextMenu(menu, view, menuInfo); getSherlockActivity().getMenuInflater().inflate(R.menu.context_menu_formulaeditor_userlist, menu); menu.findItem(R.id.context_formula_editor_userlist_delete).setVisible(true); }/*from w ww. j ava 2 s . c om*/ }
From source file:tn.iac.radiostreaming.SectionFragment.java
/** * Context Menu : when operating a long press on a radio channel *//*from w w w . j a v a 2s. co m*/ @Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); LinearLayout layout = (LinearLayout) ((AdapterContextMenuInfo) menuInfo).targetView; String radioName = ((TextView) (layout).getChildAt(1)).getText().toString(); menu.setHeaderTitle(radioName); getActivity().getMenuInflater().inflate(R.menu.context_menu, menu); radio = RadioManager.find(RadioDB.COL_NAME, radioName); if (radio.isFavorite()) { menu.findItem(R.id.menu_context_favorite).setTitle(R.string.option_unset_favorite); } }
From source file:edu.mit.mobile.android.livingpostcards.CardListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { getActivity().getMenuInflater().inflate(R.menu.activity_card_view, menu); final Cursor c = mAdapter.getCursor(); if (c == null) { return;/*from w w w. ja v a 2 s .co m*/ } final String myUserUri = Authenticator.getUserUri(getActivity()); final boolean isEditable = PrivatelyAuthorable.canEdit(myUserUri, c); menu.findItem(R.id.delete).setVisible(isEditable); menu.findItem(R.id.edit).setVisible(isEditable); menu.setHeaderTitle(Card.getTitle(getActivity(), c)); Drawable icon; try { String iconUrl = c.getString(c.getColumnIndexOrThrow(Card.COL_COVER_PHOTO)); if (iconUrl == null || iconUrl.length() == 0) { iconUrl = c.getString(c.getColumnIndexOrThrow(Card.COL_THUMBNAIL)); } icon = mImageCache.loadImage(0, Uri.parse(iconUrl), (int) (133 * mDensity), (int) (100 * mDensity)); if (icon != null) { menu.setHeaderIcon(new InsetDrawable(icon, (int) (5 * mDensity))); } } catch (final IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.mozilla.gecko.home.HistoryPanel.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); if (!RestrictedProfiles.isAllowed(getActivity(), Restriction.DISALLOW_CLEAR_HISTORY)) { menu.findItem(R.id.home_remove).setVisible(false); }// www . j a v a 2 s .co m }
From source file:nu.firetech.android.pactrack.frontend.ParcelListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.parcel_menu, menu); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; boolean enabled = (Preferences.getPreferences(getActivity()).getCheckInterval() > 0); MenuItem autoInclude = menu.findItem(R.id.action_auto_include); autoInclude.setEnabled(enabled);//from www. ja va2 s . c om autoInclude.setChecked(enabled && mDbAdapter.getAutoUpdate(info.id)); }
From source file:de.winniehell.battlebeavers.ui.GameListActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.game_list_activity); final Settings settings = ((App) getApplication()).getSettings(); Log.d(TAG, "This is player " + settings.getPlayer().getId()); Intent intent = new Intent(GameListActivity.this, Client.class); if (!bindService(intent, client, Service.BIND_AUTO_CREATE)) { Log.e(TAG, getString(R.string.error_binding_client)); return;// w w w . jav a 2s . com } intent = new Intent(GameListActivity.this, Server.class); if (!bindService(intent, server, Service.BIND_AUTO_CREATE)) { Log.e(TAG, getString(R.string.error_binding_server)); return; } announcedGames = new GameListView(this) { @Override protected void onPrepareContextMenu(final MenuInflater pInflater, final ContextMenu pMenu, final Game pGame) { pInflater.inflate(R.menu.context_announced_game, pMenu); pMenu.findItem(R.id.context_menu_join) .setVisible(pGame.isInState(GameListActivity.this, GameState.ANNOUNCED) && !pGame.isServer(getSettings().getPlayer())); } @Override public boolean onMenuItemClick(final MenuItem pItem) { final Game game = getSelectedItem(); if (game == null) { return false; } setSelection(-1); switch (pItem.getItemId()) { case R.id.context_menu_join: { Log.d(TAG, "Trying to join " + game + "..."); try { client.getService().joinGame(game); } catch (final RemoteException e) { ((ClientRemoteException) e).log(); } tabHost.setCurrentTabByTag(TAB_RUNNING); return true; } default: return false; } } }; announcedGames.setAdapter(new GameListAdapter() { @Override protected Game[] fetchList() { try { return client.getService().getAnnouncedGames(); } catch (final RemoteException e) { ((ClientRemoteException) e).log(); } return null; } }); runningGames = new GameListView(this) { @Override protected void onPrepareContextMenu(final MenuInflater pInflater, final ContextMenu pMenu, final Game pGame) { pInflater.inflate(R.menu.context_running_game, pMenu); pMenu.findItem(R.id.context_menu_load_game).setVisible(pGame.isInState(GameListActivity.this, GameState.PLANNING_PHASE, GameState.EXECUTION_PHASE)); } @Override public boolean onMenuItemClick(final MenuItem pItem) { final Game game = getSelectedItem(); if (game == null) { return false; } setSelection(-1); switch (pItem.getItemId()) { case R.id.context_menu_load_game: { showGame(game); return true; } default: return false; } } }; runningGames.setAdapter(new GameListAdapter() { @Override protected Game[] fetchList() { try { return client.getService().getRunningGames(); } catch (final RemoteException e) { ((ClientRemoteException) e).log(); } return null; } }); tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(); addTab(TAB_RUNNING, R.string.menu_running_games, runningGames); addTab(TAB_ANNOUNCED, R.string.menu_announced_games, announcedGames); tabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(final String tabId) { updateGameList(); } }); tabHost = (TabHost) findViewById(android.R.id.tabhost); updateReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { updateGameList(); } }; Log.d(TAG, "onCreate() finished"); }
From source file:org.cowboycoders.cyclisimo.BikeListActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); getMenuInflater().inflate(R.menu.user_list_context_menu, menu); MenuItem deleteMenuItem = menu.findItem(R.id.list_context_menu_delete); deleteMenuItem.setVisible(isRecording()); MenuItem editMenuItem = menu.findItem(R.id.list_context_menu_edit); editMenuItem.setVisible(isRecording()); }
From source file:com.ultramegasoft.flavordex2.fragment.CatListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); final Activity activity = getActivity(); if (activity == null) { return;/* w ww . j a v a2s . c o m*/ } final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; if (mAdapter.getShowAllCats() && info.position == 0) { return; } activity.getMenuInflater().inflate(R.menu.cat_context_menu, menu); if (mAdapter.getItem(info.position).preset) { menu.findItem(R.id.menu_delete).setEnabled(false).setVisible(false); } }
From source file:com.github.kanata3249.ffxieq.android.AugmentSelectorActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.augmentselector_context, menu); MenuItem item = menu.findItem(R.id.DeleteAugment); if (item != null) { item.setEnabled(mLongClickingItemId != mAugID); }/*from ww w . j a v a2 s.c o m*/ }
From source file:org.peterbaldwin.vlcremote.fragment.PlaylistFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (menuInfo instanceof AdapterContextMenuInfo) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; PlaylistItem item = mAdapter.getItem(info.position); MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.playlist_context, menu); MenuItem searchItem = menu.findItem(R.id.playlist_context_search); searchItem.setVisible(isSearchable(item)); }/*from w w w . j a v a 2 s. c om*/ }