Example usage for android.view Menu clear

List of usage examples for android.view Menu clear

Introduction

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

Prototype

public void clear();

Source Link

Document

Remove all existing items from the menu, leaving it empty as if it had just been created.

Usage

From source file:ua.com.spacetv.mycookbook.fragments.FragTextRecipe.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    if (startupMode == MODE_REVIEW_RECIPE)
        inflater.inflate(R.menu.menu_review_recipe, menu);
    else if (startupMode == MODE_EDIT_RECIPE | startupMode == MODE_NEW_RECIPE)
        inflater.inflate(R.menu.menu_edit_recipe, menu);
}

From source file:net.news.inrss.fragment.EntriesListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    this.menu = menu;
    menu.clear(); // This is needed to remove a bug on Android 4.0.3
    inflater.inflate(R.menu.entry_list, menu);
    if (!PrefUtils.getBoolean(PrefUtils.MARK_AS_READ, false)) {
        menu.findItem(R.id.menu_all_read).setVisible(false);
    }//from w w  w  .j av  a  2s.c om
    if (EntryColumns.FAVORITES_CONTENT_URI.equals(mUri)) {
        menu.findItem(R.id.menu_refresh).setVisible(false);
    } else {
        menu.findItem(R.id.menu_share_starred).setVisible(false);
    }
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.near.chimerarevo.activities.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.clear();
    getMenuInflater().inflate(R.menu.main, menu);
    return true;/*from w  ww.j av  a  2  s.  c o  m*/
}

From source file:com.cyanogenmod.effem.FmRadio.java

/**
 * Sets up the options menu when the menu button is pushed, dynamic
 * population of the station select menu
 *//* w ww  . j av a  2  s.co  m*/
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    boolean result = super.onCreateOptionsMenu(menu);

    // Create and populate the band selection menu
    SubMenu subMenu = menu.addSubMenu(BASE_OPTION_MENU, FM_BAND, Menu.NONE, R.string.band_select);
    subMenu.setIcon(android.R.drawable.ic_menu_mapmode);
    subMenu.add(BAND_SELECTION_MENU, BAND_US, Menu.NONE, R.string.band_us);
    subMenu.add(BAND_SELECTION_MENU, BAND_EU, Menu.NONE, R.string.band_eu);
    subMenu.add(BAND_SELECTION_MENU, BAND_JAPAN, Menu.NONE, R.string.band_ja);
    subMenu.add(BAND_SELECTION_MENU, BAND_CHINA, Menu.NONE, R.string.band_ch);
    subMenu.setGroupCheckable(BAND_SELECTION_MENU, true, true);
    subMenu.getItem(mSelectedBand).setChecked(true);

    // Create and populate the speaker/headset selection menu if speaker supported
    if (context.getResources().getBoolean(R.bool.speaker_supported)) {
        subMenu = menu.addSubMenu(BASE_OPTION_MENU, OUTPUT_SOUND, Menu.NONE, R.string.output_select);
        subMenu.setIcon(android.R.drawable.ic_menu_mapmode);
        subMenu.add(LOUDSPEAKER_SELECTION_MENU, OUTPUT_HEADSET, Menu.NONE, R.string.output_select_default);
        subMenu.add(LOUDSPEAKER_SELECTION_MENU, OUTPUT_SPEAKER, Menu.NONE, R.string.output_select_loudspeaker);
        subMenu.setGroupCheckable(LOUDSPEAKER_SELECTION_MENU, true, true);
        subMenu.getItem(mSelectedOutput).setChecked(true);
    }

    // Create the station select menu
    subMenu = menu.addSubMenu(BASE_OPTION_MENU, STATION_SELECT, Menu.NONE, R.string.station_select);
    subMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    // Dynamically populate the station select menu
    if (mMenuAdapter.isEmpty()) {
        subMenu.setGroupEnabled(STATION_SELECTION_MENU, false);
    } else {
        subMenu.setGroupEnabled(STATION_SELECTION_MENU, true);
        for (int i = 0; i < mMenuAdapter.getCount(); i++) {
            subMenu.add(STATION_SELECTION_MENU, STATION_SELECT_MENU_ITEMS + i, Menu.NONE,
                    mMenuAdapter.getItem(i).toString());
        }
    }
    return result;
}

From source file:com.eusecom.attendance.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    menu.clear();
    String ustypex = SettingsActivity.getUsType(this);
    if (ustypex.equals("99")) {
        getMenuInflater().inflate(R.menu.options_mainallmenu, menu);
    } else {//from  w  ww  .  j a v  a 2s  . c  o m
        getMenuInflater().inflate(R.menu.options_mainmenu, menu);
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.activiti.android.app.fragments.settings.AccountSettingsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    if (!DisplayUtils.hasCentralPane(getActivity())) {
        menu.clear();
        inflater.inflate(R.menu.account, menu);
    } else {//from w w w  .ja v  a  2  s.  c  o m
        getToolbar().getMenu().clear();
        getToolbar().inflateMenu(R.menu.account);
        getToolbar().setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                return onOptionsItemSelected(item);
            }
        });

    }
}

From source file:com.flowzr.activity.Report2DChartActivity.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    inflater.inflate(R.menu.report2d_actions, menu);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.android.mms.ui.MailBoxMessageContent.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();

    if (MessageUtils.hasIccCard()) {
        menu.add(0, MENU_CALL_RECIPIENT, 0, R.string.menu_call).setIcon(R.drawable.ic_menu_call)
                .setTitle(R.string.menu_call).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }/*ww  w .  j a  v a 2  s  .  c om*/

    if (mMsgType == Sms.MESSAGE_TYPE_INBOX) {
        menu.add(0, MENU_REPLY, 0, R.string.menu_reply);
        menu.add(0, MENU_FORWARD, 0, R.string.menu_forward);
        menu.add(0, MENU_DELETE, 0, R.string.delete);
    } else if (mMsgType == Sms.MESSAGE_TYPE_FAILED || mMsgType == Sms.MESSAGE_TYPE_OUTBOX) {
        menu.add(0, MENU_FORWARD, 0, R.string.menu_forward);
        menu.add(0, MENU_RESEND, 0, R.string.menu_resend);
        menu.add(0, MENU_DELETE, 0, R.string.delete);
    } else if (mMsgType == Sms.MESSAGE_TYPE_SENT) {
        menu.add(0, MENU_FORWARD, 0, R.string.menu_forward);
        menu.add(0, MENU_RESEND, 0, R.string.menu_resend);
        menu.add(0, MENU_DELETE, 0, R.string.delete);
    } else if (mMsgType == Sms.MESSAGE_TYPE_QUEUED) {
        menu.add(0, MENU_FORWARD, 0, R.string.menu_forward);
        menu.add(0, MENU_DELETE, 0, R.string.delete);
    }

    if (isLockMessage()) {
        menu.add(0, MENU_LOCK, 0, R.string.menu_unlock);
    } else {
        menu.add(0, MENU_LOCK, 0, R.string.menu_lock);
    }

    if (!Contact.get(mMsgFrom, false).existsInDatabase()) {
        menu.add(0, MENU_SAVE_TO_CONTACT, 0, R.string.menu_add_to_contacts_cm);
    }

    return true;
}

From source file:org.thoughtcrime.securesms.VerifyIdentityActivity.java

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

    menu.clear();
    MenuInflater inflater = this.getMenuInflater();
    inflater.inflate(R.menu.verify_identity, menu);

    return true;/*from   w  w  w.  j  ava  2  s  .c o  m*/
}