Example usage for android.view MenuItem setEnabled

List of usage examples for android.view MenuItem setEnabled

Introduction

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

Prototype

public MenuItem setEnabled(boolean enabled);

Source Link

Document

Sets whether the menu item is enabled.

Usage

From source file:lrstudios.util.android.ui.BetterFragmentActivity.java

/**
 * Enables or disables the specified item of the Action Bar.
 * Return false if the item was not found.
 *///  w  ww. j  a  va  2s. c om
protected boolean setOptionItemEnabled(int itemMenuId, boolean enabled) {
    if (_optionsMenu == null)
        return false;

    MenuItem item = _optionsMenu.findItem(itemMenuId);
    if (item == null)
        return false;

    item.setEnabled(enabled);
    return true;
}

From source file:net.sf.golly.SettingsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // add main.xml items to the action bar
    getMenuInflater().inflate(R.menu.main, menu);

    // disable the item for this activity
    MenuItem item = menu.findItem(R.id.settings);
    item.setEnabled(false);

    return true;/*from  w  w  w  .  jav  a  2  s.  com*/
}

From source file:com.github.nicktgn.mvp_sample.ui.NoteFragment.java

@Override
public void enableUndo(boolean enable) {
    MenuItem undo = mEditToolsMenu.getMenu().findItem(R.id.action_undo);
    undo.setEnabled(enable);
    undo.setIcon(enable ? R.drawable.ic_undo_white_24dp : R.drawable.ic_undo_grey_700_24dp);
}

From source file:com.github.nicktgn.mvp_sample.ui.NoteFragment.java

@Override
public void enableRedo(boolean enable) {
    MenuItem redo = mEditToolsMenu.getMenu().findItem(R.id.action_redo);
    redo.setEnabled(enable);
    redo.setIcon(enable ? R.drawable.ic_redo_white_24dp : R.drawable.ic_redo_grey_700_24dp);
}

From source file:com.google.devrel.samples.memedroid.app.CreateActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item = menu.findItem(R.id.menu_create);
    if (item != null) {
        item.setEnabled(mHasText);
        if (item.getIcon() != null) {
            item.getIcon().setAlpha(mHasText ? 255 : 100);
        }//from   w  w  w .  j a v a  2s  . c  o m
    }
    return super.onPrepareOptionsMenu(menu);
}

From source file:bbct.android.common.activity.FilterCards.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    MenuItem confirm = menu.findItem(R.id.save_menu);

    if (this.numberChecked() > 0) {
        confirm.setVisible(true);//from   w w  w  . ja v a2 s  . co  m
        confirm.setEnabled(true);
    } else {
        confirm.setVisible(false);
        confirm.setEnabled(false);
    }
}

From source file:net.wespot.pim.compat.view.InqDataCollectionTaskCompatFragment.java

public void setEnabledDisabled(MenuItem item, boolean shouldBeEnabled) {
    if (shouldBeEnabled) {
        item.setEnabled(true);
        item.getIcon().setAlpha(255);//from   w  w w .  j  a v  a  2  s . c o m
    } else {
        // disabled
        item.setEnabled(false);
        item.getIcon().setAlpha(130);
    }
}

From source file:com.github.michalbednarski.intentslab.browser.RegisteredReceiverInfoFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.component_info, menu);
    MenuItem packageInfoOption = menu.findItem(R.id.package_info);
    boolean packageInfoAvailable = mPackageName != null;
    packageInfoOption.setVisible(packageInfoAvailable);
    packageInfoOption.setEnabled(packageInfoAvailable);
}

From source file:de.androvdr.fragments.ChannelsFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = mActivity.getMenuInflater();
    inflater.inflate(R.menu.channels_menu, menu);
    AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
    menu.setHeaderTitle(mController.getChannelName(mi.position));

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mActivity);
    if (mSearchTime != 0) {
        menu.removeItem(R.id.cm_remote);
        menu.removeItem(R.id.cm_livetv);
    } else if (!sp.getBoolean("livetv_enabled", false)) {
        menu.removeItem(R.id.cm_livetv);
    }//  w  w w . j a  v a2s  .  co m

    if (Preferences.useInternet && !Preferences.getVdr().extremux) {
        MenuItem menuitem = menu.findItem(R.id.cm_livetv);
        if (menuitem != null)
            menuitem.setEnabled(false);
    }
}