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.etuldan.sparss.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, true)) {
        menu.findItem(R.id.menu_all_read).setVisible(false);
    }//from w w  w . jav  a 2  s .c  o m
    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:org.digitalcampus.oppia.activity.DownloadMediaActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    getMenuInflater().inflate(R.menu.missing_media_sortby, menu);
    MenuItem selectAll = menu.findItem(R.id.menu_select_all);
    if (selectAll != null) {
        selectAll.setVisible(missingMedia.size() != 0);
    }//from w  w w .j a v  a 2 s.co m

    MenuItem sortBy = menu.findItem(R.id.menu_sort_by);
    if (sortBy != null) {
        sortBy.setVisible(missingMedia.size() != 0);
        sortBy.setTitle(isSortByCourse ? getString(R.string.menu_sort_by_filename)
                : getString(R.string.menu_sort_by_course));
    }
    return true;
}

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

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.clear();
    if (!((MainActivity) mActivity).mNavigationDrawerFragment.isDrawerOpen()) {
        inflater.inflate(R.menu.plays, menu);
    }/*from  w ww.  j  a  v a2s  . c om*/
}

From source file:de.qspool.clementineremote.ui.fragments.LibraryFragment.java

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

    inflater.inflate(R.menu.library_menu, menu);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.alfresco.mobile.android.application.fragments.preferences.AccountSettingsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    MenuItem mi = menu.add(Menu.NONE, R.id.menu_account_delete, Menu.FIRST + 10, R.string.delete);
    mi.setIcon(R.drawable.ic_clear_grey);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    if (SessionManager.getInstance(getActivity()).hasSession(account.getId())) {
        mi = menu.add(Menu.NONE, R.id.my_profile, Menu.FIRST, R.string.my_profile);
        mi.setIcon(R.drawable.ic_account_circle_grey);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }//from   www  .j  a v  a2 s. com
}

From source file:me.piebridge.prevent.ui.UserGuideActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.clear();
    if (BuildConfig.DONATE && donateView.getVisibility() == View.GONE) {
        menu.add(Menu.NONE, R.string.donate, Menu.NONE, R.string.donate);
    }// w ww.j a v  a 2  s. c  om
    menu.add(Menu.NONE, R.string.version, Menu.NONE, R.string.version);
    if (BuildConfig.DONATE) {
        menu.add(Menu.NONE, R.string.feedback, Menu.NONE, R.string.feedback);
        if (TextUtils.isEmpty(LicenseUtils.getLicense(this))) {
            menu.add(Menu.NONE, R.string.request_license, Menu.NONE, R.string.request_license);
        }
    }
    menu.add(Menu.NONE, R.string.advanced_settings, Menu.NONE, R.string.advanced_settings);
    return super.onCreateOptionsMenu(menu);
}

From source file:net.simonvt.cathode.ui.fragment.EpisodeFragment.java

private void createMenu(Toolbar toolbar) {
    Menu menu = toolbar.getMenu();
    menu.clear();

    toolbar.inflateMenu(R.menu.activity_base);

    if (loaded) {
        if (checkedIn) {
            menu.add(0, R.id.action_checkin_cancel, 1, R.string.action_checkin_cancel)
                    .setIcon(R.drawable.ic_action_cancel).setShowAsActionFlags(
                            isTablet ? MenuItem.SHOW_AS_ACTION_NEVER : MenuItem.SHOW_AS_ACTION_ALWAYS);
        } else if (!watching) {
            menu.add(0, R.id.action_checkin, 2, R.string.action_checkin).setIcon(R.drawable.ic_action_checkin)
                    .setShowAsActionFlags(
                            isTablet ? MenuItem.SHOW_AS_ACTION_NEVER : MenuItem.SHOW_AS_ACTION_ALWAYS);
        }/*from  ww  w  .j  ava2  s  .c  om*/

        if (watched) {
            menu.add(0, R.id.action_unwatched, 3, R.string.action_unwatched);
        } else {
            menu.add(0, R.id.action_watched, 4, R.string.action_watched);
            if (inWatchlist) {
                menu.add(0, R.id.action_watchlist_remove, 5, R.string.action_watchlist_remove);
            } else {
                menu.add(0, R.id.action_watchlist_add, 6, R.string.action_watchlist_add);
            }
        }

        if (collected) {
            menu.add(0, R.id.action_collection_remove, 7, R.string.action_collection_remove);
        } else {
            menu.add(0, R.id.action_collection_add, 8, R.string.action_collection_add);
        }
    }
}

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

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    inflater.inflate(R.menu.global, menu);
    MenuItem graph = menu.findItem(R.id.graph);
    MenuItem log = menu.findItem(R.id.log);
    MenuItem search = menu.findItem(R.id.search);
    search.setVisible(false);/*from w  ww.j  a  va 2  s  .c o m*/
    graph.setVisible(true);
    log.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:de.qspool.clementineremote.ui.ConnectActivity.java

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

    MenuInflater inf = getMenuInflater();
    inf.inflate(R.menu.connectdialog_menu, menu);

    return true;//from w  w  w. j  a va2s .  c o m
}

From source file:de.qspool.clementineremote.ui.fragments.PlaylistFragment.java

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

    super.onCreateOptionsMenu(menu, inflater);
}