Example usage for android.view Menu removeItem

List of usage examples for android.view Menu removeItem

Introduction

In this page you can find the example usage for android.view Menu removeItem.

Prototype

public void removeItem(int id);

Source Link

Document

Remove the item with the given identifier.

Usage

From source file:ch.bfh.instacircle.NetworkActiveActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.activity_network_active, menu);

    // only display the NFC action if NFC is available
    if (!this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
        menu.removeItem(R.id.write_nfc_tag);
    }//w  w  w  .  j  a va 2  s. c  o m
    return true;
}

From source file:tkj.android.homecontrol.mythmote.MythMote.java

/**
 * Called when the menu is opened./*from  ww w  .ja  va  2s. c  o  m*/
 */
@Override
public boolean onMenuOpened(int featureId, Menu menu) {

    if (null != menu) {

        //get donate menu item
        MenuItem menuItem = menu.findItem(DONATE_ID);

        //if donate menu item exists and the user wants it gone remove it
        if (null != menuItem && !sShowDonateMenuItem)
            menu.removeItem(DONATE_ID);

        //if the donate button is missing and the user wants it add it back
        if (null == menuItem && sShowDonateMenuItem)
            menu.add(0, DONATE_ID, 0, R.string.donate_menu_item_str).setIcon(R.drawable.paypal);
    }
    return super.onMenuOpened(featureId, menu);
}

From source file:com.dattasmoon.pebble.plugin.EditNotificationActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.activity_edit_notifications, menu);
    if (mode == Mode.LOCALE) {
        menu.removeItem(R.id.btnSettings);
    }/*from  ww  w  .j a va  2 s  .c  o m*/
    return true;
}

From source file:org.ohmage.reminders.types.location.LocTrigMapsActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    boolean ret = super.onPrepareOptionsMenu(menu);

    menu.removeItem(MENU_SATELLITE_ID);

    int txt = R.string.trigger_loc_menu_satellite_mode;
    if (mMap.getMapType() == GoogleMap.MAP_TYPE_SATELLITE) {
        txt = R.string.trigger_loc_menu_map_mode;
    }//from ww  w . j a  va2s. c o m

    menu.add(0, MENU_SATELLITE_ID, 3, txt).setIcon(android.R.drawable.ic_menu_mapmode);

    return ret;
}

From source file:org.namelessrom.devicecontrol.appmanager.AppDetailsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_app_details, menu);

    if (mAppItem != null) {
        if (!AppHelper.isPlayStoreInstalled()) {
            menu.removeItem(R.id.menu_action_play_store);
        }/*from w ww .  jav a 2s. c  o  m*/
        // prevent disabling Device Control
        if (Application.get().getPackageName().equals(mAppItem.getPackageName())) {
            menu.removeItem(R.id.menu_app_disable);
        }

        final MenuItem disable = menu.findItem(R.id.menu_app_disable);
        if (disable != null) {
            disable.setTitle(mAppItem.isEnabled() ? R.string.disable : R.string.enable);
        }
    } else {
        menu.removeItem(R.id.menu_action_play_store);
        menu.removeItem(R.id.menu_app_disable);
    }

    return true;
}

From source file:com.audiokernel.euphonyrmt.fragments.QueueFragment.java

@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.mpd_playlistmenu, menu);
    menu.removeItem(R.id.PLM_EditPL);
}

From source file:com.farmerbb.notepad.fragment.NoteEditFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.note_edit, menu);

    if (listener.isShareIntent() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        menu.removeItem(R.id.action_export);
        menu.removeItem(R.id.action_print);
    }//from  w  ww  . ja v a 2s .c  o m
}

From source file:github.popeen.dsub.fragments.SelectPodcastsFragment.java

@Override
public void onCreateContextMenu(Menu menu, MenuInflater menuInflater, UpdateView<Serializable> updateView,
        Serializable item) {//www . j a  va2s. c  o m
    if (item instanceof PodcastChannel) {
        PodcastChannel channel = (PodcastChannel) item;
        if (!Util.isOffline(context) && UserUtil.canPodcast()) {
            menuInflater.inflate(R.menu.select_podcasts_context, menu);

            if (SyncUtil.isSyncedPodcast(context, channel.getId())) {
                menu.removeItem(R.id.podcast_menu_sync);
            } else {
                menu.removeItem(R.id.podcast_menu_stop_sync);
            }
        } else {
            menuInflater.inflate(R.menu.select_podcasts_context_offline, menu);
        }
    } else {
        onCreateContextMenuSupport(menu, menuInflater, updateView, item);
    }
    recreateContextMenu(menu);
}

From source file:io.mapsquare.osmcontributor.ui.activities.MapActivity.java

@Subscribe(threadMode = ThreadMode.MAIN)
public void onPleaseInitializeNoteDrawerEvent(PleaseInitializeNoteDrawerEvent event) {
    Menu menu = filterView.getMenu();
    if (!FlavorUtils.isPoiStorage()) {
        displayOpenNotes = event.isDisplayOpenNotes();
        displayClosedNotes = event.isDisplayClosedNotes();

        menu.findItem(R.id.display_open_notes_item).setChecked(displayOpenNotes);
        menu.findItem(R.id.display_closed_notes_item).setChecked(displayClosedNotes);
    } else {/*from   w  w w. ja va  2s.com*/
        menu.removeItem(R.id.drawer_filter_notes_menu);
    }
}

From source file:uk.org.downiesoft.slideshow.SlidesFragment.java

/**
 * {@inheritDoc}//from   w w  w .  j  ava  2s. com
 */
@Override
public boolean onPrepareActionMode(ActionMode p1, Menu p2) {
    Window window = getActivity().getWindow();
    //      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    //         window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 
    //         window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 
    //         window.setStatusBarColor(mColorBlueOverlay);
    //         window.setNavigationBarColor(mColorBlackOverlay);
    //      }
    if (sPresentation.getType() == Presentation.LIST_PRESENTATION) {
        p2.removeItem(R.id.action_add_favourite);
    }
    return true;
}