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:com.apptentive.android.sdk.module.engagement.interaction.fragment.ApptentiveBaseFragment.java

@Override
public void onDestroyView() {
    super.onDestroyView();
    if (toolbar != null && fragmentMenuItems != null) {
        Menu toolbarMenu = toolbar.getMenu();
        Iterator it = fragmentMenuItems.iterator();
        // Remove menu items added by this fragment
        while (it.hasNext()) {
            Integer menuItem = (Integer) it.next();

            toolbarMenu.removeItem(menuItem.intValue());
        }/*from ww w.  j a v a2 s.  c o m*/
    }

}

From source file:eu.istvank.apps.lenslog.fragments.NavigationDrawerFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // If the drawer is open, show the global app actions in the action bar. See also
    // showGlobalContextActionBar, which controls the top-left area of the action bar.
    if (mDrawerLayout != null && isDrawerOpen()) {
        inflater.inflate(R.menu.global, menu);

        // do not show Settings item if showing Settings fragment
        Fragment frgSettings = getFragmentManager().findFragmentByTag(MainActivity.FRAGMENT_SETTINGS);
        if (frgSettings != null && frgSettings.isVisible()) {
            menu.removeItem(R.id.action_settings);
        }//from  w  ww  . j  av a  2 s  .c  o m

        showGlobalContextActionBar();
    }
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:de.ub0r.android.callmeter.ui.Plans.java

/**
 * {@inheritDoc}/*from   w w w. j  a va  2 s.  co  m*/
 */
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    if (prefsNoAds) {
        menu.removeItem(R.id.item_donate);
    }
    return true;
}

From source file:net.sourceforge.servestream.fragment.BrowseFragment.java

private void showPopup(View v, UriBean uri) {
    mSelectedMenuItem = uri;/*from  w w  w . j  a  v  a  2s . c o m*/

    PopupMenu popup = new PopupMenu(getActivity(), v);
    Menu menu = popup.getMenu();
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.browse_uri_actions, menu);
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (bluetoothAdapter == null) {
        menu.removeItem(R.id.menu_autostart_on_bluetooth);
    }
    popup.setOnMenuItemClickListener(mPopupMenuOnMenuItemClickListener);
    popup.show();
}

From source file:li.klass.fhem.activities.core.FragmentBaseActivity.java

@SuppressLint("NewApi")
@Override/*  www.j  a v a 2 s. c  o  m*/
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main_menu, menu);
    if (getPackageName().equals(PREMIUM_PACKAGE)) {
        menu.removeItem(R.id.menu_premium);
    }
    this.optionsMenu = menu;

    MenuItem refreshItem = optionsMenu.findItem(R.id.menu_refresh);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        if (showProgressIcon) {
            refreshItem.setActionView(R.layout.actionbar_indeterminate_progress);
        } else {
            refreshItem.setActionView(null);
        }
    }

    return super.onCreateOptionsMenu(menu);
}

From source file:de.blinkt.openvpn.fragments.LogFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.logmenu, menu);
    if (getResources().getBoolean(R.bool.logSildersAlwaysVisible))
        menu.removeItem(R.id.toggle_time);
}

From source file:net.sf.diningout.app.ui.FriendsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    if (!mListener.onFriendsOptionsMenu()) {
        return;// w  w  w . j  ava 2s.  c  o  m
    }
    inflater.inflate(R.menu.friends, menu);
    if (mInit) {
        menu.removeItem(R.id.search);
    } else {
        MenuItem item = menu.findItem(R.id.search);
        mSearch = (SearchView) item.getActionView();
        mSearch.setSearchableInfo(Managers.search(a).getSearchableInfo(a.getComponentName()));
        SearchViews.setBackground(mSearch, R.drawable.textfield_searchview);
        mSearch.setOnSearchClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                event("friends", "search");
            }
        });
        mSearch.setOnQueryTextListener(new SearchTextListener());
        item.setOnActionExpandListener(new SearchExpandListener());
    }
    if (!Intents.hasActivity(a, sAddIntent)) {
        menu.removeItem(R.id.add);
    }
}

From source file:net.sourceforge.servestream.fragment.UrlListFragment.java

private void showPopup(View v, UriBean uri) {
    mSelectedMenuItem = uri;//from  w w w  .  j  av a2 s  .c  o  m

    PopupMenu popup = new PopupMenu(getActivity(), v);
    Menu menu = popup.getMenu();
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.uri_list_uri_actions, menu);
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (bluetoothAdapter == null) {
        menu.removeItem(R.id.menu_autostart_on_bluetooth);
    }
    popup.setOnMenuItemClickListener(mPopupMenuOnMenuItemClickListener);
    popup.show();
}

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

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

    mShareActionProvider = (MaterialShareActionProvider) MenuItemCompat
            .getActionProvider(menu.findItem(R.id.action_share));

    if (args == null)
        return true;

    if (args.containsKey(Constants.KEY_URL) && !args.containsKey(Constants.KEY_ID))
        menu.removeItem(R.id.action_favorite);
    else if (args.containsKey(Constants.KEY_ID)) {
        mFavoriteItem = menu.findItem(R.id.action_favorite);

        DatabaseHelper db = new DatabaseHelper(this);
        isSaved = db.hasFavourite(args.getInt(Constants.KEY_ID));
        if (isSaved) {
            mFavoriteItem.setTitle(getResources().getString(R.string.action_remove_favorite));
            mFavoriteItem.setIcon(getResources().getDrawable(R.drawable.ic_action_favorite));
        }/*  w w  w.j a  v  a  2s .co  m*/
        db.close();
    }

    return true;
}

From source file:com.ninetwozero.battlelog.PlatoonActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {

    // Our own profile, no need to show the "extra" buttons
    if (viewPager.getCurrentItem() == 0) {

        return super.onPrepareOptionsMenu(fragmentOverview.prepareOptionsMenu(menu));

    } else if (viewPager.getCurrentItem() == 1) {

        return super.onPrepareOptionsMenu(fragmentStats.prepareOptionsMenu(menu));

    } else if (viewPager.getCurrentItem() == 2) {

        return super.onPrepareOptionsMenu(fragmentMember.prepareOptionsMenu(menu));

    } else {/*from w  w w.ja v  a 2 s.  c  o m*/

        menu.removeItem(R.id.option_friendadd);
        menu.removeItem(R.id.option_frienddel);
        menu.removeItem(R.id.option_compare);
        menu.removeItem(R.id.option_unlocks);

    }

    return super.onPrepareOptionsMenu(menu);

}