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:com.example.rps.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    // only add the menu when the selection fragment is showing
    if (fragments[RPS].isVisible()) {
        if (menu.size() == 0) {
            share = menu.add(R.string.share_on_facebook);
            message = menu.add(R.string.send_with_messenger);
            challenge = menu.add(R.string.challenge_friends);
            settings = menu.add(R.string.check_settings);
            invite = menu.add(R.string.invite_friends);
        }/*from www  .  j  a va 2 s .  c om*/
        return true;
    } else {
        menu.clear();
        settings = null;
    }
    return false;
}

From source file:mn.today.TheHubActivity.java

@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
    menu.clear();
    getMenuInflater().inflate(R.menu.menu_the_hub, menu);

    MenuItem newF = menu.findItem(R.id.action_new_flow);
    //        MenuItem deleteAllF = menu.findItem(R.id.action_delete_flows);
    if (menuState.equals(AppConstants.MENU_ITEMS_HIDE)) {
        newF.setVisible(false);/*w ww  .  ja v  a 2  s.c  om*/
        //            deleteAllF.setVisible(false);
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:net.archenemy.archenemyapp.presenter.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    menu.clear();

    if (getVisibleFragment() == twitterPageFragment) {
        inflater.inflate(R.menu.twitter, menu);
        return true;
    }/*from   ww  w  .  j  a  v  a  2  s .co  m*/

    if (getVisibleFragment() == facebookPageFragment) {
        inflater.inflate(R.menu.facebook, menu);
        return true;
    }

    // default
    inflater.inflate(R.menu.main, menu);
    return true;
}

From source file:com.example.igorklimov.popularmoviesdemo.fragments.DetailFragment.java

private void setupToolbar() {
    if (!isTabletPreference(context)) {
        ((DetailActivity) context).setSupportActionBar(mBar);
        ActionBar supportActionBar = ((DetailActivity) context).getSupportActionBar();
        supportActionBar.setDisplayHomeAsUpEnabled(true);
        supportActionBar.setDisplayShowTitleEnabled(false);
        ((DetailActivity) context).getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_home);
    } else {// ww w. j  av a2s. c o m
        Menu menu = mBar.getMenu();
        if (null != menu)
            menu.clear();
        mBar.inflateMenu(R.menu.menu_detail);
        finishCreatingMenu(mBar.getMenu());
    }
}

From source file:com.lastsoft.plog.GamesFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.clear();
    if (playListType != 2 && !((MainActivity) mActivity).mNavigationDrawerFragment.isDrawerOpen()
            && ((MainActivity) mActivity).currentFragmentCode != 0) {
        inflater.inflate(R.menu.games, menu);
        menuItem0 = menu.getItem(0);//from  ww w  .  java2s. c o m
        if (showExpansions) {
            menuItem0.setTitle(getString(R.string.hide_expansions));
            menuItem0.setIcon(R.drawable.ic_visibility_off);
        } else {
            menuItem0.setTitle(getString(R.string.show_expansions));
            menuItem0.setIcon(R.drawable.ic_visibility);
        }
    } else if (playListType == 2 && !((MainActivity) mActivity).mNavigationDrawerFragment.isDrawerOpen()
            && ((MainActivity) mActivity).currentFragmentCode != 0) {
        inflater.inflate(R.menu.bucketlist, menu);
    }
}

From source file:com.ultramegasoft.flavordex2.fragment.EntryListFragment.java

/**
 * Set up the list Toolbar if it exists.
 *///from ww w . j a va2 s.c o m
@SuppressLint("PrivateResource")
private void setupToolbar() {
    final EntryListActivity activity = (EntryListActivity) getActivity();
    if (activity == null) {
        return;
    }

    mToolbar = activity.findViewById(R.id.list_toolbar);
    if (mToolbar != null) {
        mToolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material);
        mToolbar.setNavigationContentDescription(R.string.abc_action_bar_up_description);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                activity.onCatSelected(-1, false);
            }
        });
        final Menu menu = mToolbar.getMenu();
        menu.clear();
        mToolbar.inflateMenu(R.menu.entry_list_menu);
        mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                return onOptionsItemSelected(item);
            }
        });
        setupMenu(menu);
    } else {
        setHasOptionsMenu(true);
        final ActionBar actionBar = activity.getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    }
}

From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java

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

From source file:org.mklab.mikity.android.SceneGraphTreeFragment.java

/**
 * {@inheritDoc}/*from  w w  w  . ja  va2s . c o  m*/
 */
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    menu.clear();
    inflater.inflate(R.menu.menu_model, menu);
}

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

void populateOptionsMenu() {
    final Menu menu = getMenu();
    final MenuBuilder mb = menu instanceof MenuBuilder ? (MenuBuilder) menu : null;
    if (mb != null) {
        mb.stopDispatchingItemsChanged();
    }//from ww w . j  a v  a 2  s. c  om
    try {
        menu.clear();
        if (!mWindowCallback.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu)
                || !mWindowCallback.onPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu)) {
            menu.clear();
        }
    } finally {
        if (mb != null) {
            mb.startDispatchingItemsChanged();
        }
    }
}

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

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

    menu.add(0, MENU_MSG_FOLDER, 0, R.string.menu_msg_folder).setIcon(R.drawable.ic_menu_folder);

    menu.add(0, MENU_COMPOSE_NEW, 0, R.string.menu_compose_new)
            .setIcon(com.android.internal.R.drawable.ic_menu_compose);

    if (mListAdapter.getCount() > 0) {
        menu.add(0, MENU_DELETE_ALL, 0, R.string.menu_delete_all).setIcon(android.R.drawable.ic_menu_delete);
    }// w w w.j  av  a  2 s .c  o  m

    menu.add(0, MENU_SEARCH, 0, android.R.string.search_go).setIcon(android.R.drawable.ic_menu_search)
            .setAlphabeticShortcut(android.app.SearchManager.MENU_KEY);

    menu.add(0, MENU_PREFERENCES, 0, R.string.menu_preferences).setIcon(android.R.drawable.ic_menu_preferences);

    menu.add(0, MENU_CBSMS, 0, R.string.cell_broadcast_sms).setIcon(R.drawable.menu_cb);

    return true;
}