Example usage for android.view Menu findItem

List of usage examples for android.view Menu findItem

Introduction

In this page you can find the example usage for android.view Menu findItem.

Prototype

public MenuItem findItem(int id);

Source Link

Document

Return the menu item with a particular identifier.

Usage

From source file:com.orange.ocara.ui.activity.ResultAuditActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    boolean ret = super.onPrepareOptionsMenu(menu);
    menu.findItem(com.orange.ocara.R.id.action_lock)
            .setVisible(!Audit.Status.TERMINATED.equals(audit.getStatus()));
    return ret;//from www  .  j a va  2  s.com
}

From source file:com.example.javier.MaterialDesignApp.PlayerActivity.java

public void showVerboseLogPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    Menu menu = popup.getMenu();
    menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal);
    menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose);
    menu.setGroupCheckable(Menu.NONE, true, true);
    menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true);
    popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override/*from  w  w w .j  av  a  2s  .  co  m*/
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == 0) {
                VerboseLogUtil.setEnableAllTags(false);
            } else {
                VerboseLogUtil.setEnableAllTags(true);
            }
            return true;
        }
    });
    popup.show();
}

From source file:com.almarsoft.GroundhogReader.MessageActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    int textSize = mPrefs.getInt("webViewTextSize", UsenetConstants.TEXTSIZE_NORMAL);

    MenuItem bigtext = menu.findItem(R.id.message_menu_bigtext);
    MenuItem smalltext = menu.findItem(R.id.message_menu_smalltext);

    if (textSize == UsenetConstants.TEXTSIZE_LARGEST)
        bigtext.setEnabled(false);/*w  ww.  j  av a2  s .c o m*/
    else
        bigtext.setEnabled(true);

    if (textSize == UsenetConstants.TEXTSIZE_SMALLEST)
        smalltext.setEnabled(false);
    else
        smalltext.setEnabled(true);
    return (super.onPrepareOptionsMenu(menu));

}

From source file:com.matthewmitchell.peercoin_android_wallet.ui.WalletActivity.java

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

    getMenuInflater().inflate(R.menu.wallet_options, menu);
    menu.findItem(R.id.wallet_options_donate).setVisible(!Constants.TEST);

    return true;/*from ww w. java  2  s.  c  om*/
}

From source file:com.freecast.LudoCast.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    Log.d(TAG, "onCreateOptionsMenu() was called");
    getMenuInflater().inflate(R.menu.main, menu);
    mediaRouteMenuItem = mCastManager.addMediaRouterButton(menu, R.id.media_route_menu_item);
    mAppConnected = mCastManager.isConnected();
    MenuItem actionRestart = menu.findItem(R.id.menu_restart);
    actionRestart.setVisible(false);//ww  w  . ja  v a2s . c  o  m
    //MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    //MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat
    //      .getActionProvider(mediaRouteMenuItem);
    // Set the MediaRouteActionProvider selector for device discovery.
    //mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
    return true;
}

From source file:com.taw.gotothere.GoToThereActivity.java

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

    MenuItem refresh = menu.findItem(R.id.refresh);
    if (!navigating) {
        // Disable the refresh menu item initially; it's re-enabled when the
        // user's navigating
        refresh.setEnabled(false);//  ww w . j  a v a2  s  . c  o  m
    } else {
        refresh.setEnabled(true);
    }

    return true;
}

From source file:butter.droid.base.fragments.BaseVideoPlayerFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.activity_player, menu);
    menu.findItem(R.id.action_reload).setVisible(mShowReload);
}

From source file:com.example.android.navigationdrawerexample.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    // If the nav drawer is open, hide action items related to the content view
    boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
    menu.findItem(R.id.action_websearch).setVisible(!drawerOpen);
    menu.findItem(R.id.cart).setVisible(!drawerOpen);
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.gmail.boiledorange73.ut.map.MapActivityBase.java

private void activateMenuItemIfExists(Menu menu, int id) {
    MenuItem item = menu.findItem(id);
    if (item != null) {
        item.setVisible(true);//w  ww  .j  a  v a  2 s . c o  m
    }
}

From source file:br.com.mybaby.contatos.ContactDetailFragment.java

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

    // Inflates the options menu for this fragment
    inflater.inflate(R.menu.contatos_detail_menu, menu);

    // Gets a handle to the "find" menu item
    mEditContactMenuItem = menu.findItem(R.id.menu_edit_contact);

    // If contactUri is null the edit menu item should be hidden, otherwise
    // it is visible.
    mEditContactMenuItem.setVisible(mContactUri != null);
}