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:nu.firetech.android.pactrack.frontend.ParcelDetailsFragment.java

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

    boolean enabled = (Preferences.getPreferences(getActivity()).getCheckInterval() > 0);
    MenuItem autoInclude = menu.findItem(R.id.action_auto_include);
    autoInclude.setEnabled(enabled);
    autoInclude.setChecked(enabled && mDbAdapter.getAutoUpdate(mRowId));
}

From source file:io.realm.scanner.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem item = menu.getItem(0);
    item.setEnabled(false);
    return true;/*from www.j a  va2 s. c o  m*/
}

From source file:th.in.ffc.person.visit.VisitDefaultActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.save:
        item.setEnabled(false);
        doSave();/*w  w w  . j  a va  2 s . c  om*/
        item.setEnabled(true);
        return true;
    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.TwitterUpdatesFragment.java

/**
 * {@inheritDoc}/*from w  w w.j a v a 2 s .c  om*/
 */
@Override
public void onPrepareOptionsMenu(final Menu menu) {
    super.onPrepareOptionsMenu(menu);

    final MenuItem refreshItem = menu.findItem(R.id.newsupdates_option_menu_refresh);

    if (progress.getVisibility() == View.VISIBLE) {
        // Disable the refresh item if a refresh is in progress.
        refreshItem.setEnabled(false);
    } else {
        // Enable the refresh item otherwise.
        refreshItem.setEnabled(true);
    }
}

From source file:info.wncwaterfalls.app.InformationMapFragment.java

private void enableOfflineMapToggle() {
    if (mOptionsMenuCreated && mOfflineMapCreated) {
        MenuItem item = mOptionsMenu.findItem(R.id.menu_item_map_show_overlay);
        if (item != null) {
            item.setEnabled(true);
        }/*  w w w  . j a  v a2  s  .c o m*/
    }
}

From source file:net.sf.golly.OpenActivity.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.open);
    item.setEnabled(false);

    return true;/* ww w .  j av a2  s .  c  o m*/
}

From source file:com.mikecorrigan.trainscorekeeper.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    Log.vc(VERBOSE, TAG, "onPrepareOptionsMenu: menu=" + menu);

    super.onPrepareOptionsMenu(menu);

    MenuItem item = menu.findItem(R.id.new_game);
    item.setEnabled(true);

    item = menu.findItem(R.id.undo);//  w w  w .jav a 2s .  c  o  m
    item.setEnabled(undoEnabled());

    item = menu.findItem(R.id.redo);
    item.setEnabled(redoEnabled());

    return true;
}

From source file:com.owncloud.android.files.FileMenuFilter.java

private void hideAll(Menu menu) {
    MenuItem item;
    for (int i = 0; i < menu.size(); i++) {
        item = menu.getItem(i);//w  ww.  java 2 s.c  om
        item.setVisible(false);
        item.setEnabled(false);
    }
}

From source file:org.totschnig.myexpenses.util.Utils.java

/**
 * Credit:/* w ww . ja  v  a2s. co m*/
 * https://groups.google.com/forum/?fromgroups#!topic/actionbarsherlock
 * /Z8Ic8djq-3o
 *
 * @param item
 * @param enabled
 */
public static void menuItemSetEnabledAndVisible(MenuItem item, boolean enabled) {
    item.setEnabled(enabled).setVisible(enabled);
}

From source file:com.github.pockethub.android.ui.gist.GistFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    boolean owner = isOwner();
    if (!owner) {
        menu.removeItem(R.id.m_delete);/*from w w  w  .ja  v  a2s  . com*/
        MenuItem starItem = menu.findItem(R.id.m_star);
        starItem.setEnabled(loadFinished && !owner);
        if (starred) {
            starItem.setTitle(R.string.unstar);
        } else {
            starItem.setTitle(R.string.star);
        }
    } else {
        menu.removeItem(R.id.m_star);
    }
}