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:org.mozilla.gecko.BrowserApp.java

private void updateAddonMenuItem(int id, JSONObject options) {
    // Set attribute for the menu item in cache, if available
    if (mAddonMenuItemsCache != null && !mAddonMenuItemsCache.isEmpty()) {
        for (MenuItemInfo item : mAddonMenuItemsCache) {
            if (item.id == id) {
                item.label = options.optString("name", item.label);
                item.checkable = options.optBoolean("checkable", item.checkable);
                item.checked = options.optBoolean("checked", item.checked);
                item.enabled = options.optBoolean("enabled", item.enabled);
                item.visible = options.optBoolean("visible", item.visible);
                item.added = (mMenu != null);
                break;
            }// ww  w . j a v  a 2s .co m
        }
    }

    if (mMenu == null) {
        return;
    }

    final MenuItem menuItem = mMenu.findItem(id);
    if (menuItem != null) {
        menuItem.setTitle(options.optString("name", menuItem.getTitle().toString()));
        menuItem.setCheckable(options.optBoolean("checkable", menuItem.isCheckable()));
        menuItem.setChecked(options.optBoolean("checked", menuItem.isChecked()));
        menuItem.setEnabled(options.optBoolean("enabled", menuItem.isEnabled()));
        menuItem.setVisible(options.optBoolean("visible", menuItem.isVisible()));
    }
}

From source file:org.mozilla.gecko.BrowserApp.java

/**
 * Add the provided item to the provided menu, which should be
 * the root (mMenu).//from   w ww .j  a  v a2  s .  co m
 */
private void addAddonMenuItemToMenu(final Menu menu, final MenuItemInfo info) {
    info.added = true;

    final Menu destination;
    if (info.parent == 0) {
        destination = menu;
    } else if (info.parent == GECKO_TOOLS_MENU) {
        // The tools menu only exists in our -v11 resources.
        if (Versions.feature11Plus) {
            final MenuItem tools = menu.findItem(R.id.tools);
            destination = tools != null ? tools.getSubMenu() : menu;
        } else {
            destination = menu;
        }
    } else {
        final MenuItem parent = menu.findItem(info.parent);
        if (parent == null) {
            return;
        }

        Menu parentMenu = findParentMenu(menu, parent);

        if (!parent.hasSubMenu()) {
            parentMenu.removeItem(parent.getItemId());
            destination = parentMenu.addSubMenu(Menu.NONE, parent.getItemId(), Menu.NONE, parent.getTitle());
            if (parent.getIcon() != null) {
                ((SubMenu) destination).getItem().setIcon(parent.getIcon());
            }
        } else {
            destination = parent.getSubMenu();
        }
    }

    final MenuItem item = destination.add(Menu.NONE, info.id, Menu.NONE, info.label);

    item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Menu:Clicked",
                    Integer.toString(info.id - ADDON_MENU_OFFSET)));
            return true;
        }
    });

    if (info.icon == null) {
        item.setIcon(R.drawable.ic_menu_addons_filler);
    } else {
        final int id = info.id;
        BitmapUtils.getDrawable(this, info.icon, new BitmapUtils.BitmapLoader() {
            @Override
            public void onBitmapFound(Drawable d) {
                // TODO: why do we re-find the item?
                final MenuItem item = destination.findItem(id);
                if (item == null) {
                    return;
                }
                if (d == null) {
                    item.setIcon(R.drawable.ic_menu_addons_filler);
                    return;
                }
                item.setIcon(d);
            }
        });
    }

    item.setCheckable(info.checkable);
    item.setChecked(info.checked);
    item.setEnabled(info.enabled);
    item.setVisible(info.visible);
}

From source file:org.mozilla.gecko.BrowserApp.java

@Override
public boolean onPrepareOptionsMenu(Menu aMenu) {
    if (aMenu == null)
        return false;

    // Hide the tab history panel when hardware menu button is pressed.
    TabHistoryFragment frag = (TabHistoryFragment) getSupportFragmentManager()
            .findFragmentByTag(TAB_HISTORY_FRAGMENT_TAG);
    if (frag != null) {
        frag.dismiss();/*from   ww  w.  j a  v  a  2 s.c  o m*/
    }

    if (!GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
        aMenu.findItem(R.id.settings).setEnabled(false);
        aMenu.findItem(R.id.help).setEnabled(false);
    }

    Tab tab = Tabs.getInstance().getSelectedTab();
    final MenuItem bookmark = aMenu.findItem(R.id.bookmark);
    final MenuItem reader = aMenu.findItem(R.id.reading_list);
    final MenuItem back = aMenu.findItem(R.id.back);
    final MenuItem forward = aMenu.findItem(R.id.forward);
    final MenuItem share = aMenu.findItem(R.id.share);
    final MenuItem quickShare = aMenu.findItem(R.id.quickshare);
    final MenuItem saveAsPDF = aMenu.findItem(R.id.save_as_pdf);
    final MenuItem charEncoding = aMenu.findItem(R.id.char_encoding);
    final MenuItem findInPage = aMenu.findItem(R.id.find_in_page);
    final MenuItem desktopMode = aMenu.findItem(R.id.desktop_mode);
    final MenuItem enterGuestMode = aMenu.findItem(R.id.new_guest_session);
    final MenuItem exitGuestMode = aMenu.findItem(R.id.exit_guest_session);

    // Only show the "Quit" menu item on pre-ICS, television devices,
    // or if the user has explicitly enabled the clear on shutdown pref.
    // (We check the pref last to save the pref read.)
    // In ICS+, it's easy to kill an app through the task switcher.
    final boolean visible = Versions.preICS || HardwareUtils.isTelevision() || !PrefUtils
            .getStringSet(GeckoSharedPrefs.forProfile(this), ClearOnShutdownPref.PREF, new HashSet<String>())
            .isEmpty();
    aMenu.findItem(R.id.quit).setVisible(visible);
    aMenu.findItem(R.id.logins).setVisible(AppConstants.NIGHTLY_BUILD);

    if (tab == null || tab.getURL() == null) {
        bookmark.setEnabled(false);
        reader.setEnabled(false);
        back.setEnabled(false);
        forward.setEnabled(false);
        share.setEnabled(false);
        quickShare.setEnabled(false);
        saveAsPDF.setEnabled(false);
        findInPage.setEnabled(false);

        // NOTE: Use MenuUtils.safeSetEnabled because some actions might
        // be on the BrowserToolbar context menu.
        if (Versions.feature11Plus) {
            // There is no page menu prior to v11 resources.
            MenuUtils.safeSetEnabled(aMenu, R.id.page, false);
        }
        MenuUtils.safeSetEnabled(aMenu, R.id.subscribe, false);
        MenuUtils.safeSetEnabled(aMenu, R.id.add_search_engine, false);
        MenuUtils.safeSetEnabled(aMenu, R.id.site_settings, false);
        MenuUtils.safeSetEnabled(aMenu, R.id.add_to_launcher, false);

        return true;
    }

    final boolean inGuestMode = GeckoProfile.get(this).inGuestMode();

    final boolean isAboutReader = AboutPages.isAboutReader(tab.getURL());
    bookmark.setEnabled(!isAboutReader);
    bookmark.setVisible(!inGuestMode);
    bookmark.setCheckable(true);
    bookmark.setChecked(tab.isBookmark());
    bookmark.setIcon(resolveBookmarkIconID(tab.isBookmark()));
    bookmark.setTitle(resolveBookmarkTitleID(tab.isBookmark()));

    reader.setEnabled(isAboutReader || !AboutPages.isAboutPage(tab.getURL()));
    reader.setVisible(!inGuestMode);
    reader.setCheckable(true);
    final boolean isPageInReadingList = tab.isInReadingList();
    reader.setChecked(isPageInReadingList);
    reader.setIcon(resolveReadingListIconID(isPageInReadingList));
    reader.setTitle(resolveReadingListTitleID(isPageInReadingList));

    back.setEnabled(tab.canDoBack());
    forward.setEnabled(tab.canDoForward());
    desktopMode.setChecked(tab.getDesktopMode());
    desktopMode.setIcon(
            tab.getDesktopMode() ? R.drawable.ic_menu_desktop_mode_on : R.drawable.ic_menu_desktop_mode_off);

    View backButtonView = MenuItemCompat.getActionView(back);

    if (backButtonView != null) {
        backButtonView.setOnLongClickListener(new Button.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                Tab tab = Tabs.getInstance().getSelectedTab();
                if (tab != null) {
                    closeOptionsMenu();
                    return tabHistoryController.showTabHistory(tab, TabHistoryController.HistoryAction.BACK);
                }
                return false;
            }
        });
    }

    View forwardButtonView = MenuItemCompat.getActionView(forward);

    if (forwardButtonView != null) {
        forwardButtonView.setOnLongClickListener(new Button.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                Tab tab = Tabs.getInstance().getSelectedTab();
                if (tab != null) {
                    closeOptionsMenu();
                    return tabHistoryController.showTabHistory(tab, TabHistoryController.HistoryAction.FORWARD);
                }
                return false;
            }
        });
    }

    String url = tab.getURL();
    if (AboutPages.isAboutReader(url)) {
        String urlFromReader = ReaderModeUtils.getUrlFromAboutReader(url);
        if (urlFromReader != null) {
            url = urlFromReader;
        }
    }

    // Disable share menuitem for about:, chrome:, file:, and resource: URIs
    final boolean shareVisible = RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_SHARE);
    share.setVisible(shareVisible);
    final boolean shareEnabled = StringUtils.isShareableUrl(url) && shareVisible;
    share.setEnabled(shareEnabled);
    MenuUtils.safeSetEnabled(aMenu, R.id.downloads,
            RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_DOWNLOADS));

    // NOTE: Use MenuUtils.safeSetEnabled because some actions might
    // be on the BrowserToolbar context menu.
    if (Versions.feature11Plus) {
        MenuUtils.safeSetEnabled(aMenu, R.id.page, !isAboutHome(tab));
    }
    MenuUtils.safeSetEnabled(aMenu, R.id.subscribe, tab.hasFeeds());
    MenuUtils.safeSetEnabled(aMenu, R.id.add_search_engine, tab.hasOpenSearch());
    MenuUtils.safeSetEnabled(aMenu, R.id.site_settings, !isAboutHome(tab));
    MenuUtils.safeSetEnabled(aMenu, R.id.add_to_launcher, !isAboutHome(tab));

    // Action providers are available only ICS+.
    if (Versions.feature14Plus) {
        quickShare.setVisible(shareVisible);
        quickShare.setEnabled(shareEnabled);

        // This provider also applies to the quick share menu item.
        final GeckoActionProvider provider = ((GeckoMenuItem) share).getGeckoActionProvider();
        if (provider != null) {
            Intent shareIntent = provider.getIntent();

            // For efficiency, the provider's intent is only set once
            if (shareIntent == null) {
                shareIntent = new Intent(Intent.ACTION_SEND);
                shareIntent.setType("text/plain");
                provider.setIntent(shareIntent);
            }

            // Replace the existing intent's extras
            shareIntent.putExtra(Intent.EXTRA_TEXT, url);
            shareIntent.putExtra(Intent.EXTRA_SUBJECT, tab.getDisplayTitle());
            shareIntent.putExtra(Intent.EXTRA_TITLE, tab.getDisplayTitle());
            shareIntent.putExtra(ShareDialog.INTENT_EXTRA_DEVICES_ONLY, true);

            // Clear the existing thumbnail extras so we don't share an old thumbnail.
            shareIntent.removeExtra("share_screenshot_uri");

            // Include the thumbnail of the page being shared.
            BitmapDrawable drawable = tab.getThumbnail();
            if (drawable != null) {
                Bitmap thumbnail = drawable.getBitmap();

                // Kobo uses a custom intent extra for sharing thumbnails.
                if (Build.MANUFACTURER.equals("Kobo") && thumbnail != null) {
                    File cacheDir = getExternalCacheDir();

                    if (cacheDir != null) {
                        File outFile = new File(cacheDir, "thumbnail.png");

                        try {
                            java.io.FileOutputStream out = new java.io.FileOutputStream(outFile);
                            thumbnail.compress(Bitmap.CompressFormat.PNG, 90, out);
                        } catch (FileNotFoundException e) {
                            Log.e(LOGTAG, "File not found", e);
                        }

                        shareIntent.putExtra("share_screenshot_uri", Uri.parse(outFile.getPath()));
                    }
                }
            }
        }
    }

    final boolean privateTabVisible = RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_PRIVATE_BROWSING);
    MenuUtils.safeSetVisible(aMenu, R.id.new_private_tab, privateTabVisible);

    // Disable save as PDF for about:home and xul pages.
    saveAsPDF.setEnabled(!(isAboutHome(tab) || tab.getContentType().equals("application/vnd.mozilla.xul+xml")
            || tab.getContentType().startsWith("video/")));

    // Disable find in page for about:home, since it won't work on Java content.
    findInPage.setEnabled(!isAboutHome(tab));

    charEncoding.setVisible(GeckoPreferences.getCharEncodingState());

    if (mProfile.inGuestMode()) {
        exitGuestMode.setVisible(true);
    } else {
        enterGuestMode.setVisible(true);
    }

    if (!RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_GUEST_BROWSING)) {
        MenuUtils.safeSetVisible(aMenu, R.id.new_guest_session, false);
    }

    if (!RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_INSTALL_EXTENSION)) {
        MenuUtils.safeSetVisible(aMenu, R.id.addons, false);
    }

    return true;
}

From source file:com.bernard.beaconportal.activities.activity.MessageList.java

/**
 * Hide menu items not appropriate for the current context.
 * //from w  w w .  ja v  a2  s  .  com
 * <p>
 * <strong>Note:</strong> Please adjust the comments in
 * {@code res/menu/message_list_option.xml} if you change the visibility of
 * a menu item in this method.
 * </p>
 * 
 * @param mMenu2
 *            The {@link Menu} instance that should be modified. May be
 *            {@code null}; in that case the method does nothing and
 *            immediately returns.
 */
private void configureMenu(android.view.Menu mMenu2) {
    if (mMenu2 == null) {
        return;
    }

    // Set visibility of account/folder settings menu items
    if (mMessageListFragment == null) {
        mMenu2.findItem(R.id.account_settings).setVisible(false);
        mMenu2.findItem(R.id.folder_settings).setVisible(false);
    } else {
        mMenu2.findItem(R.id.account_settings).setVisible(mMessageListFragment.isSingleAccountMode());
        mMenu2.findItem(R.id.folder_settings).setVisible(mMessageListFragment.isSingleFolderMode());
    }

    /*
     * Set visibility of menu items related to the message view
     */

    if (mDisplayMode == DisplayMode.MESSAGE_LIST || mMessageViewFragment == null
            || !mMessageViewFragment.isInitialized()) {
        mMenu2.findItem(R.id.next_message).setVisible(false);
        mMenu2.findItem(R.id.previous_message).setVisible(false);
        mMenu2.findItem(R.id.single_message_options).setVisible(false);
        mMenu2.findItem(R.id.delete).setVisible(false);
        mMenu2.findItem(R.id.composeList).setVisible(false);
        mMenu2.findItem(R.id.composeView).setVisible(false);
        mMenu2.findItem(R.id.archive).setVisible(false);
        mMenu2.findItem(R.id.move).setVisible(false);
        mMenu2.findItem(R.id.copy).setVisible(false);
        mMenu2.findItem(R.id.spam).setVisible(false);
        mMenu2.findItem(R.id.refile).setVisible(false);
        mMenu2.findItem(R.id.toggle_unread).setVisible(false);
        mMenu2.findItem(R.id.select_text).setVisible(false);
        mMenu2.findItem(R.id.toggle_message_view_theme).setVisible(false);
        mMenu2.findItem(R.id.show_headers).setVisible(false);
        mMenu2.findItem(R.id.hide_headers).setVisible(false);

        final int splitBarId = getResources().getIdentifier("split_action_bar", "id", "android");
        final View splitActionBar = findViewById(splitBarId);

        SharedPreferences sharedpref = getSharedPreferences("actionbar_color", Context.MODE_PRIVATE);

        if (!sharedpref.contains("actionbar_color")) {

            if (splitActionBar != null) {

                splitActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#4285f4")));

            }

        } else {

            actionbar_colors = sharedpref.getString("actionbar_color", null);

            if (splitActionBar != null) {

                splitActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(actionbar_colors)));
            }

        }

    } else {
        // hide prev/next buttons in split mode
        if (mDisplayMode != DisplayMode.MESSAGE_VIEW) {
            mMenu2.findItem(R.id.next_message).setVisible(false);
            mMenu2.findItem(R.id.previous_message).setVisible(false);
        } else {
            MessageReference ref = mMessageViewFragment.getMessageReference();
            boolean initialized = (mMessageListFragment != null && mMessageListFragment.isLoadFinished());
            boolean canDoPrev = (initialized && !mMessageListFragment.isFirst(ref));
            boolean canDoNext = (initialized && !mMessageListFragment.isLast(ref));

            MenuItem prev = mMenu2.findItem(R.id.previous_message);
            prev.setEnabled(canDoPrev);
            // prev.getIcon().setAlpha(canDoPrev ? 255 : 127);

            // MenuItem next = menu.findItem(R.id.next_message);
            // next.setEnabled(canDoNext);
            // next.getIcon().setAlpha(canDoNext ? 255 : 127);

            final int splitBarId = getResources().getIdentifier("split_action_bar", "id", "android");
            final View splitActionBar = findViewById(splitBarId);

            if (splitActionBar != null) {

                splitActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#ffffff")));
            }

        }

        MenuItem toggleTheme = mMenu2.findItem(R.id.toggle_message_view_theme);
        if (K9.useFixedMessageViewTheme()) {
            toggleTheme.setVisible(false);
        } else {
            // Set title of menu item to switch to dark/light theme
            if (K9.getK9MessageViewTheme() == K9.Theme.DARK) {
                toggleTheme.setTitle(R.string.message_view_theme_action_light);
            } else {
                toggleTheme.setTitle(R.string.message_view_theme_action_dark);
            }
            toggleTheme.setVisible(true);
        }

        // Set title of menu item to toggle the read state of the currently
        // displayed message
        if (mMessageViewFragment.isMessageRead()) {
            mMenu2.findItem(R.id.toggle_unread).setTitle(R.string.mark_as_unread_action);
        } else {
            mMenu2.findItem(R.id.toggle_unread).setTitle(R.string.mark_as_read_action);
        }

        // Jellybean has built-in long press selection support
        mMenu2.findItem(R.id.select_text).setVisible(Build.VERSION.SDK_INT < 16);

        mMenu2.findItem(R.id.delete).setVisible(K9.isMessageViewDeleteActionVisible());

        /*
         * Set visibility of copy, move, archive, spam in action bar and
         * refile submenu
         */
        if (mMessageViewFragment.isCopyCapable()) {
            mMenu2.findItem(R.id.copy).setVisible(K9.isMessageViewCopyActionVisible());
            mMenu2.findItem(R.id.refile_copy).setVisible(true);
        } else {
            mMenu2.findItem(R.id.copy).setVisible(false);
            mMenu2.findItem(R.id.refile_copy).setVisible(false);
        }

        if (mMessageViewFragment.isMoveCapable()) {
            boolean canMessageBeArchived = mMessageViewFragment.canMessageBeArchived();
            boolean canMessageBeMovedToSpam = mMessageViewFragment.canMessageBeMovedToSpam();

            mMenu2.findItem(R.id.move).setVisible(K9.isMessageViewMoveActionVisible());
            mMenu2.findItem(R.id.archive)
                    .setVisible(canMessageBeArchived && K9.isMessageViewArchiveActionVisible());
            mMenu2.findItem(R.id.spam)
                    .setVisible(canMessageBeMovedToSpam && K9.isMessageViewSpamActionVisible());

            mMenu2.findItem(R.id.refile_move).setVisible(true);
            mMenu2.findItem(R.id.refile_archive).setVisible(canMessageBeArchived);
            mMenu2.findItem(R.id.refile_spam).setVisible(canMessageBeMovedToSpam);
        } else {
            mMenu2.findItem(R.id.move).setVisible(false);
            mMenu2.findItem(R.id.archive).setVisible(false);
            mMenu2.findItem(R.id.spam).setVisible(false);

            mMenu2.findItem(R.id.refile).setVisible(false);
        }

        if (mMessageViewFragment.allHeadersVisible()) {
            mMenu2.findItem(R.id.show_headers).setVisible(false);
        } else {
            mMenu2.findItem(R.id.hide_headers).setVisible(false);
        }
    }

    /*
     * Set visibility of menu items related to the message list
     */

    // Hide both search menu items by default and enable one when
    // appropriate
    mMenu2.findItem(R.id.search).setVisible(false);
    mMenu2.findItem(R.id.search_remote).setVisible(false);

    if (mDisplayMode == DisplayMode.MESSAGE_VIEW || mMessageListFragment == null
            || !mMessageListFragment.isInitialized()) {
        mMenu2.findItem(R.id.check_mail).setVisible(false);
        mMenu2.findItem(R.id.set_sort).setVisible(false);
        mMenu2.findItem(R.id.select_all).setVisible(false);
        mMenu2.findItem(R.id.send_messages).setVisible(false);
        mMenu2.findItem(R.id.expunge).setVisible(false);
        mMenu2.findItem(R.id.mark_all_as_read).setVisible(false);
        mMenu2.findItem(R.id.show_folder_list).setVisible(false);
    } else {
        mMenu2.findItem(R.id.set_sort).setVisible(true);
        mMenu2.findItem(R.id.select_all).setVisible(true);
        mMenu2.findItem(R.id.composeList).setVisible(true);
        mMenu2.findItem(R.id.mark_all_as_read).setVisible(mMessageListFragment.isMarkAllAsReadSupported());

        if (!mMessageListFragment.isSingleAccountMode()) {
            mMenu2.findItem(R.id.expunge).setVisible(false);
            mMenu2.findItem(R.id.send_messages).setVisible(false);
            mMenu2.findItem(R.id.show_folder_list).setVisible(false);
        } else {
            mMenu2.findItem(R.id.send_messages).setVisible(mMessageListFragment.isOutbox());
            mMenu2.findItem(R.id.expunge).setVisible(
                    mMessageListFragment.isRemoteFolder() && mMessageListFragment.isAccountExpungeCapable());
            mMenu2.findItem(R.id.show_folder_list).setVisible(true);
        }

        mMenu2.findItem(R.id.check_mail).setVisible(mMessageListFragment.isCheckMailSupported());

        // If this is an explicit local search, show the option to search on
        // the server
        if (!mMessageListFragment.isRemoteSearch() && mMessageListFragment.isRemoteSearchAllowed()) {
            mMenu2.findItem(R.id.search_remote).setVisible(true);
        } else if (!mMessageListFragment.isManualSearch()) {
            mMenu2.findItem(R.id.search).setVisible(true);
        }
    }
}

From source file:com.rfo.basic.Run.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) { // Executed when Menu key is pressed (before onCreateOptionsMenu() above.

    super.onPrepareOptionsMenu(menu);
    MenuItem item;
    if (Stop) { // If program running display with Editor dimmed
        item = menu.getItem(0); // Other wise dim Stop and undim Editor
        item.setEnabled(false);
        item = menu.getItem(1);//from   www.  j  av  a  2  s. c  o  m
        item.setEnabled(true);
    }
    return true;
}

From source file:com.rfo.basic.Run.java

@Override
public boolean onCreateOptionsMenu(Menu menu) { // Called when the menu key is pressed.
    super.onCreateOptionsMenu(menu);
    if (!Settings.getConsoleMenu(this)) {
        return false;
    }/*from  ww w  .j av  a  2s.  com*/

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.run, menu);
    MenuItem item = menu.getItem(1);
    if (Basic.DoAutoRun) { // If APK or shortcut, menu action is "Exit", not "Editor"
        item.setTitle(getString(R.string.exit));
    }
    item.setEnabled(false);
    return true;
}