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:net.goldenspiral.fetlifeoss.ui.fragments.FetLifeFragment.java

/**
 * Initialize the contents of the Activity's standard options menu.  You
 * should place your menu items in to <var>menu</var>.  For this method
 * to be called, you must have first called {@link #setHasOptionsMenu}.  See
 * {@link android.app.Activity#onCreateOptionsMenu(Menu) Activity.onCreateOptionsMenu}
 * for more information./*from   ww w  . ja  va2  s.c o m*/
 *
 * @param menu     The options menu in which you place your items.
 * @param inflater
 * @see #setHasOptionsMenu
 * @see #onPrepareOptionsMenu
 * @see #onOptionsItemSelected
 */
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();

    int resId = getOptionMenuResId();
    if (resId == 0)
        return;

    inflater.inflate(resId, menu);
    MenuItem item = menu.findItem(R.id.menu_share);
    if (item != null) {
        shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
        if (lastShareIntent != null)
            shareActionProvider.setShareIntent(lastShareIntent);
    }
}

From source file:com.cypress.cysmart.BLEServiceFragments.CapsenseService.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    inflater.inflate(R.menu.global, menu);
    ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null) {
        actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    }//  w  ww .  jav  a2s .  c om
    MenuItem graph = menu.findItem(R.id.graph);
    MenuItem log = menu.findItem(R.id.log);
    MenuItem search = menu.findItem(R.id.search);
    search.setVisible(false);
    graph.setVisible(false);
    log.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.yangtsaosoftware.pebblemessenger.activities.SetupFragment.java

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

}

From source file:android.support.v7.app.BaseTestActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    mMenu = menu;/* w w  w . j a va 2s . c o  m*/
    if (mShouldPopulateOptionsMenu) {
        getMenuInflater().inflate(R.menu.sample_actions, menu);
        return true;
    } else {
        menu.clear();
        return super.onCreateOptionsMenu(menu);
    }
}

From source file:com.raspi.chatapp.ui.image.SingleImageFragment.java

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

From source file:com.jwork.dhammapada.ChapterFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    //      SearchView searchView = new SearchView(getSherlockActivity().getSupportActionBar().getThemedContext());
    //        searchView.setQueryHint("Search for sutta");
    //        searchView.setOnQueryTextListener(this);
    //        searchView.setOnSuggestionListener(this);

    //        searchView.setSuggestionsAdapter(mSuggestionsAdapter);

    //        menu.add("Search")
    //            .setIcon(R.drawable.abs__ic_search)
    //            .setActionView(searchView)
    //            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    //      SubMenu subMenu = menu.addSubMenu(Menu.NONE, 99, 99, null);
    //      //from   w w w  .  j  a v  a  2s  .c o  m
    //      inflater.inflate(R.menu.submenu_chapter, subMenu);
    //
    //       MenuItem subMenuItem = subMenu.getItem();
    //       subMenuItem.setIcon(R.drawable.ic_action_overflow);
    //       subMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}

From source file:eu.iescities.pilot.rovereto.roveretoexplorer.fragments.event.EventDetailsFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    super.onPrepareOptionsMenu(menu);
}

From source file:org.ubicompforall.cityexplorer.gui.PoiDetailsActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.poi_menu, menu);
    if (poi.isFavorite()) {
        menu.findItem(R.id.poiMenufavorite).setIcon(R.drawable.favstar_on);
    } else {/*from w w  w  .  j ava  2  s.com*/
        menu.findItem(R.id.poiMenufavorite).setIcon(R.drawable.favstar_off);
    }
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.z.blast.workbox.Calculator.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    menu.clear();
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    menu.findItem(R.id.basic).setVisible(!getBasicVisibility());
    menu.findItem(R.id.advanced).setVisible(!getAdvancedVisibility());
    return true;//from  w w w . j ava 2 s .com
}

From source file:net.idlesoft.android.apps.github.activities.Repository.java

@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
    if (menu.hasVisibleItems()) {
        menu.clear();
    }/* www. j  a v a 2  s .  c om*/
    if (mIsWatching) {
        menu.add(0, 3, 0, "Unwatch");
    } else {
        menu.add(0, 3, 0, "Watch");
    }
    menu.add(0, 0, 0, "Back to Main").setIcon(android.R.drawable.ic_menu_revert);
    menu.add(0, 1, 0, "Clear Preferences");
    menu.add(0, 2, 0, "Clear Cache");
    return true;
}