Example usage for android.view MenuItem setVisible

List of usage examples for android.view MenuItem setVisible

Introduction

In this page you can find the example usage for android.view MenuItem setVisible.

Prototype

public MenuItem setVisible(boolean visible);

Source Link

Document

Sets the visibility of the menu item.

Usage

From source file:com.decad3nce.aegis.AegisActivity.java

private void showItem(int id, Menu menu) {
    MenuItem item = menu.findItem(id);
    item.setVisible(true);
}

From source file:com.dwdesign.tweetings.fragment.SearchTweetsFragment.java

@Override
public void onPrepareOptionsMenu(final Menu menu) {
    super.onPrepareOptionsMenu(menu);
    optionsMenu = menu;/*  w w  w  . ja va 2 s  . c o  m*/

    final MenuItem itemSave = menu.findItem(MENU_SAVE);
    final MenuItem itemDelete = menu.findItem(MENU_DELETE_SUBMENU);
    if (mSearchId > 0) {
        itemSave.setVisible(false);
        itemDelete.setVisible(true);
    } else {
        itemSave.setVisible(true);
        itemDelete.setVisible(false);
    }

}

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

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();/*  www .  j a  v  a 2 s.co  m*/
    inflater.inflate(R.menu.global, menu);
    ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null) {
        actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    }
    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:org.docrj.smartcard.reader.EmvReadActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    boolean drawerOpen = mNavDrawer.isOpen();
    MenuItem item = menu.findItem(R.id.menu_share_msgs);
    item.setVisible(!drawerOpen);
    item = menu.findItem(R.id.menu_clear_msgs);
    item.setVisible(!drawerOpen);//  w w  w  .  j  a  va 2s . c  o m

    mConsole.setShareIntent();
    return true;
}

From source file:de.vanita5.twittnuker.fragment.support.UserListsListFragment.java

@Override
public void onPrepareOptionsMenu(final Menu menu) {
    final MenuItem item = menu.findItem(R.id.new_user_list);
    if (item == null)
        return;//from w  w  w.j  a  v  a2  s  . c  o m
    final long account_id = getAccountId(), user_id = getUserId();
    final String screen_name = getAccountScreenName(getActivity(), account_id);
    item.setVisible(
            user_id == account_id || screen_name != null && screen_name.equalsIgnoreCase(getScreenName()));
}

From source file:com.mtomczak.nausicaa.MainActivity.java

@Override
public boolean onPreparePanel(int featureId, View view, Menu menu) {

    if (featureId == WindowUtils.FEATURE_VOICE_COMMANDS) {
        MenuItem status = menu.findItem(R.id.status_view_option);
        status.setVisible(currentSubview != NausicaaSubview.STATUS);
        status.setEnabled(currentSubview != NausicaaSubview.STATUS);

        MenuItem docking = menu.findItem(R.id.docking_view_option);
        docking.setVisible(currentSubview != NausicaaSubview.DOCKING);
        docking.setEnabled(currentSubview != NausicaaSubview.DOCKING);

        return true;
    }/*from  w w  w.  ja  v  a  2 s.  c  o m*/
    return super.onPreparePanel(featureId, view, menu);
}

From source file:com.dm.material.dashboard.candybar.activities.CandyBarWallpaperActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_wallpaper, menu);
    MenuItem save = menu.findItem(R.id.menu_save);
    save.setVisible(getResources().getBoolean(R.bool.enable_wallpaper_download));
    return super.onCreateOptionsMenu(menu);
}

From source file:org.amahi.anywhere.activity.ServerActivity.java

private void setUpMenu(Menu menu) {
    MenuItem sortMenuItem = menu.findItem(R.id.menu_sort);

    if (sortMenuItem != null) {
        sortMenuItem.setVisible(!isNavigationDrawerOpen());
    }/*from  ww  w .  j av a2 s  . c  o m*/
}

From source file:com.openerp.addons.note.AddFollowerFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_fragment_note, menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_note_search).getActionView();
    searchView.setOnQueryTextListener(getQueryListener(listAdapters));

    searchView.setOnCloseListener(new OnCloseListener() {
        @Override/*from  ww  w.  j a  v  a 2s .  c o  m*/
        public boolean onClose() {
            getPartnersFromLocal();
            return false;
        }
    });

    // disabling the COMPOSE NOTE,WRITE,CANCEL options
    MenuItem item_compose = menu.findItem(R.id.menu_note_compose);
    item_compose.setVisible(false);
    MenuItem item_write = menu.findItem(R.id.menu_note_write);
    item_write.setVisible(false);
    MenuItem item_cancel = menu.findItem(R.id.menu_note_cancel);
    item_cancel.setVisible(false);
}

From source file:com.cuddlesoft.nori.fragment.ImageFragment.java

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

    // Set up ShareActionProvider
    MenuItem shareItem = menu.findItem(R.id.action_share);
    ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    shareActionProvider.setShareIntent(getShareIntent());

    // Hide the view on Pixiv menu item, if the Image does not have a Pixiv source URL.
    MenuItem shareOnPixivItem = menu.findItem(R.id.action_viewOnPixiv);
    if (image.pixivId == null || TextUtils.isEmpty(image.pixivId)) {
        shareOnPixivItem.setVisible(false);
    }/*from   w  w  w.  j a  v a  2  s. c  o  m*/
}