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:org.failedprojects.anjaroot.PackagesFragment.java

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

    if (isDonateAppPresent()) {
        menu.removeItem(R.id.action_buy_donate);
    }//from  w ww .  j a  va  2 s  .c o m
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.gh4a.activities.FileViewerActivity.java

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

    if (FileUtils.isImage(mPath) || FileUtils.isMarkdown(mPath)) {
        menu.removeItem(R.id.wrap);
    }//from  ww  w .  j  a v  a 2s .  c  o  m

    menu.removeItem(R.id.download);
    MenuItem item = menu.add(0, MENU_ITEM_HISTORY, Menu.NONE, R.string.history);
    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_NEVER);

    return super.onCreateOptionsMenu(menu);
}

From source file:org.akvo.flow.activity.RecordListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.records_activity, menu);
    if (!mSurveyGroup.isMonitored()) {
        menu.removeItem(R.id.sync_records);
    }//from   w ww.  j  ava2 s.  c  o  m

    // "Order By" is only available for the ListFragment, not the MapFragment.
    // The navigation components maintain 2 different indexes: Tab index and Pager index.
    // The system seems to always update the tab index first, prior to the onCreateOptionsMenu
    // call (either selecting the Tab or swiping the Pager). For this reason, we need to check
    // the Tab index, not the Pager one, which turns out to be buggy in some Android versions.
    // TODO: If this approach is still unreliable, we'll need to invalidate the menu twice.
    if (getSupportActionBar().getSelectedNavigationIndex() == POSITION_MAP) {
        menu.removeItem(R.id.order_by);
    }

    return super.onCreateOptionsMenu(menu);
}

From source file:com.near.chimerarevo.fragments.ProductFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.post, menu);
    super.onCreateOptionsMenu(menu, inflater);
    menu.removeItem(R.id.action_favorite);
    mShareActionProvider = (MaterialShareActionProvider) MenuItemCompat
            .getActionProvider(menu.findItem(R.id.action_share));
}

From source file:com.itime.team.itime.fragments.MeetingSubPreferenceFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // MeetingSubPreferenceFragment utilize the same menu in container activity
    menu.removeItem(R.id.action_add);
    inflater.inflate(R.menu.meeting_sub_preference, menu);
}

From source file:eu.inmite.apps.smsjizdenka.activity.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);
    if (App.isReleaseBuild()) {
        menu.removeItem(R.id.menu_add_testing_ticket);
    }/*from w  w  w.  j  av a 2  s  . co  m*/
    return super.onCreateOptionsMenu(menu);
}

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

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    if (requestCode == 2) {
        debug(0, "Code Two!");
        menu.removeItem(R.id.planMenuNewPoi);
        //  JF: Support for sharing removed (do not work properly)
        //         menu.removeItem(R.id.planMenuSharePois);
        //menu.removeItem(R.id.planMenuUpdatePois);
        menu.removeItem(R.id.planMenuAddPois);
    }//from   w w  w.j  a v  a  2 s.  com
    return true;
}

From source file:ca.mymenuapp.ui.activities.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (userPreference.get().isGuest()) {
        menu.removeItem(R.id.logout);
    } else {/*from   ww w.j  a  va  2  s .  co m*/
        menu.removeItem(R.id.login);
    }
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.devalladolid.musictoday.activities.BaseActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    if (!TimberUtils.hasEffectsPanel(BaseActivity.this)) {
        menu.removeItem(R.id.action_equalizer);
    }//from w ww.  j  av a 2 s  . c o m
    ATE.applyMenu(this, getATEKey(), menu);
    return true;
}

From source file:com.veniosg.dir.android.fragment.SideNavFragment.java

private void setListChoiceListener() {
    getListView().setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
        @Override//from   ww  w .jav  a2  s.com
        public boolean onPrepareActionMode(android.view.ActionMode mode, Menu menu) {
            menu.clear();
            mode.getMenuInflater().inflate(R.menu.cab_bookmarks, menu);

            if (getListView().getCheckedItemCount() != 1) {
                menu.removeItem(R.id.menu_open_parent);
            }
            return true;
        }

        @Override
        public void onDestroyActionMode(android.view.ActionMode mode) {
            setStatusBarColour(getActivity(), false);
        }

        @Override
        public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {
            setStatusBarColour(getActivity(), true);
            return true;
        }

        @Override
        public boolean onActionItemClicked(android.view.ActionMode mode, MenuItem item) {
            switch (item.getItemId()) {
            case R.id.menu_delete:
                long[] ids = getListView().getCheckedItemIds();
                for (long id : ids) {
                    getListView().getContext().getContentResolver().delete(BookmarkProvider.CONTENT_URI,
                            BookmarkProvider._ID + "=?", new String[] { "" + id });
                }
                mode.finish();
                return true;

            case R.id.menu_open_parent:
                int pos = 0;
                SparseBooleanArray checked = getListView().getCheckedItemPositions();
                for (int i = 0; i < getListView().getCount(); i++) {
                    if (checked.get(i)) {
                        pos = i;
                    }
                }

                String path = ((Cursor) getListAdapter().getItem(pos)).getString(2);
                ((BookmarkContract) getActivity()).onBookmarkSelected(new File(path).getParent());
                mode.finish();
                return true;
            }
            return false;
        }

        @Override
        public void onItemCheckedStateChanged(android.view.ActionMode mode, int position, long id,
                boolean checked) {
            if (getListView().getCheckedItemCount() != 0) {

                mode.setTitle(getListView().getCheckedItemCount() + " " + getString(R.string.selected));

                // Force actions' refresh
                mode.invalidate();
            }
        }
    });
    getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
}