Example usage for android.view MenuItem SHOW_AS_ACTION_NEVER

List of usage examples for android.view MenuItem SHOW_AS_ACTION_NEVER

Introduction

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

Prototype

int SHOW_AS_ACTION_NEVER

To view the source code for android.view MenuItem SHOW_AS_ACTION_NEVER.

Click Source Link

Document

Never show this item as a button in an Action Bar.

Usage

From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean result = super.onCreateOptionsMenu(menu);
    MenuItem item;//from   w  w w .jav a  2 s .  co m

    item = menu.add(ContextMenu.NONE, MENU_TRACKLIST, ContextMenu.NONE, R.string.menu_tracklist)
            .setIcon(R.drawable.ic_list_24dp).setAlphabeticShortcut('P');
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS);

    item = menu.add(ContextMenu.NONE, MENU_STATS, ContextMenu.NONE, R.string.menu_statistics)
            .setIcon(R.drawable.ic_graph_24dp).setAlphabeticShortcut('S');
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS);

    item = menu.add(ContextMenu.NONE, MENU_SHARE, ContextMenu.NONE, R.string.menu_shareTrack)
            .setIcon(R.drawable.ic_share_24dp).setAlphabeticShortcut('I');
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM);

    item = menu.add(ContextMenu.NONE, MENU_LAYERS, ContextMenu.NONE, R.string.menu_showLayers)
            .setIcon(R.drawable.ic_layers_24dp).setAlphabeticShortcut('L');
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM);

    item = menu.add(ContextMenu.NONE, MENU_NOTE, ContextMenu.NONE, R.string.menu_insertnote)
            .setIcon(R.drawable.ic_pin_drop_24dp);
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM);

    item = menu.add(ContextMenu.NONE, MENU_SETTINGS, ContextMenu.NONE, R.string.menu_settings)
            .setIcon(R.drawable.ic_menu_preferences).setAlphabeticShortcut('C');
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_NEVER);

    return result;
}

From source file:org.alfresco.mobile.android.application.fragments.node.browser.DocumentFolderBrowserFragment.java

public void getMenu(Menu menu) {
    if (parentFolder == null) {
        return;/* w w w.ja  va2  s . c om*/
    }

    if (getActivity() instanceof MainActivity) {
        getMenu(getSession(), menu, parentFolder);

        if (hasDocument()) {
            displayMenuItem = menu.add(Menu.NONE, R.id.menu_gallery, Menu.FIRST, R.string.display_gallery);
            displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }
    } else if (getActivity() instanceof PublicDispatcherActivity
            || getActivity() instanceof BaseShortcutActivity) {
        // permission =
        // getSession().getServiceRegistry().getDocumentFolderService().getPermissions(parentFolder);
        if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder,
                ConfigurableActionHelper.ACTION_CREATE_FOLDER)) {
            MenuItem mi = menu.add(Menu.NONE, R.id.menu_create_folder, Menu.FIRST, R.string.folder_create);
            mi.setIcon(R.drawable.ic_repository_light);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
    }

    MenuFragmentHelper.getMenu(getActivity(), menu);
}

From source file:org.uguess.android.sysinfo.ApplicationManager.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem mi = menu.add(Menu.NONE, MI_DELETE, Menu.NONE, R.string.uninstall);
    mi.setIcon(android.R.drawable.ic_menu_delete);
    Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_IF_ROOM);

    mi = menu.add(Menu.NONE, MI_SHARE, Menu.NONE, R.string.share);
    mi.setIcon(android.R.drawable.ic_menu_share);
    Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_IF_ROOM);

    if (Util.getSettingsIntent(getActivity().getPackageManager(), "com.android.settings.UsageStats") != null) //$NON-NLS-1$
    {// ww  w .  j a  v  a 2 s  . co  m
        mi = menu.add(Menu.NONE, MI_USAGE_STATS, Menu.NONE, R.string.usage_stats);
        mi.setIcon(android.R.drawable.ic_menu_recent_history);
        Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_NEVER);
    }

    mi = menu.add(Menu.NONE, MI_REVERT, Menu.NONE, R.string.restore);
    mi.setIcon(android.R.drawable.ic_menu_revert);
    Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_ALWAYS);

    mi = menu.add(Menu.NONE, MI_PREFERENCE, Menu.NONE, R.string.preference);
    mi.setIcon(android.R.drawable.ic_menu_preferences);
    Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_NEVER);
}

From source file:com.hughes.android.dictionary.DictionaryActivity.java

@Override
public boolean onCreateOptionsMenu(final Menu menu) {

    if (PreferenceManager.getDefaultSharedPreferences(this)
            .getBoolean(getString(R.string.showPrevNextButtonsKey), true)) {
        // Next word.
        nextWordMenuItem = menu.add(getString(R.string.nextWord)).setIcon(R.drawable.arrow_down_float);
        MenuItemCompat.setShowAsAction(nextWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM);
        nextWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            @Override//from  w  ww  . j ava2  s  . c o  m
            public boolean onMenuItemClick(MenuItem item) {
                onUpDownButton(false);
                return true;
            }
        });

        // Previous word.
        previousWordMenuItem = menu.add(getString(R.string.previousWord)).setIcon(R.drawable.arrow_up_float);
        MenuItemCompat.setShowAsAction(previousWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM);
        previousWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                onUpDownButton(true);
                return true;
            }
        });
    }

    randomWordMenuItem = menu.add(getString(R.string.randomWord));
    randomWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            onRandomWordButton();
            return true;
        }
    });

    application.onCreateGlobalOptionsMenu(this, menu);

    {
        final MenuItem dictionaryManager = menu.add(getString(R.string.dictionaryManager));
        MenuItemCompat.setShowAsAction(dictionaryManager, MenuItem.SHOW_AS_ACTION_NEVER);
        dictionaryManager.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            public boolean onMenuItemClick(final MenuItem menuItem) {
                startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext()));
                finish();
                return false;
            }
        });
    }

    {
        final MenuItem aboutDictionary = menu.add(getString(R.string.aboutDictionary));
        MenuItemCompat.setShowAsAction(aboutDictionary, MenuItem.SHOW_AS_ACTION_NEVER);
        aboutDictionary.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            public boolean onMenuItemClick(final MenuItem menuItem) {
                final Context context = getListView().getContext();
                final Dialog dialog = new Dialog(context);
                dialog.setContentView(R.layout.about_dictionary_dialog);
                final TextView textView = (TextView) dialog.findViewById(R.id.text);

                final String name = application.getDictionaryName(dictFile.getName());
                dialog.setTitle(name);

                final StringBuilder builder = new StringBuilder();
                final DictionaryInfo dictionaryInfo = dictionary.getDictionaryInfo();
                dictionaryInfo.uncompressedBytes = dictFile.length();
                if (dictionaryInfo != null) {
                    builder.append(dictionaryInfo.dictInfo).append("\n\n");
                    builder.append(getString(R.string.dictionaryPath, dictFile.getPath())).append("\n");
                    builder.append(getString(R.string.dictionarySize, dictionaryInfo.uncompressedBytes))
                            .append("\n");
                    builder.append(getString(R.string.dictionaryCreationTime, dictionaryInfo.creationMillis))
                            .append("\n");
                    for (final IndexInfo indexInfo : dictionaryInfo.indexInfos) {
                        builder.append("\n");
                        builder.append(getString(R.string.indexName, indexInfo.shortName)).append("\n");
                        builder.append(getString(R.string.mainTokenCount, indexInfo.mainTokenCount))
                                .append("\n");
                    }
                    builder.append("\n");
                    builder.append(getString(R.string.sources)).append("\n");
                    for (final EntrySource source : dictionary.sources) {
                        builder.append(getString(R.string.sourceInfo, source.getName(), source.getNumEntries()))
                                .append("\n");
                    }
                }
                textView.setText(builder.toString());

                dialog.show();
                final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
                layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
                layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
                dialog.getWindow().setAttributes(layoutParams);
                return false;
            }
        });
    }

    return true;
}

From source file:org.opendatakit.survey.activities.MainMenuActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    PropertiesSingleton props = CommonToolProperties.get(this, getAppName());

    int showOption = MenuItem.SHOW_AS_ACTION_IF_ROOM;
    MenuItem item;// ww w .  j a  va  2  s. c  o m
    if (currentFragment != ScreenList.WEBKIT) {
        ActionBar actionBar = getActionBar();
        actionBar.setCustomView(R.layout.action_bar);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.show();

        item = menu.add(Menu.NONE, MENU_CLOUD_FORMS, Menu.NONE, R.string.sync);
        item.setIcon(R.drawable.ic_cached_black_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

        item = menu.add(Menu.NONE, MENU_ABOUT, Menu.NONE, R.string.about);
        item.setIcon(R.drawable.ic_info_outline_black_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    } else {
        ActionBar actionBar = getActionBar();
        actionBar.hide();
    }

    return true;
}

From source file:org.odk.collect.android.activities.FormEntryActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Collect.getInstance().getActivityLogger().logInstanceAction(this, "onCreateOptionsMenu", "show");
    super.onCreateOptionsMenu(menu);

    if (!hasHardwareMenu) {
        menu.add(0, MENU_SAVE, 0, R.string.save_all_answers).setIcon(android.R.drawable.ic_menu_save)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

        menu.add(0, MENU_HIERARCHY_VIEW, 0, R.string.view_hierarchy).setIcon(R.drawable.ic_menu_goto)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }//from   w w w . j a v  a  2  s .  co m

    menu.add(0, MENU_LANGUAGES, 0, R.string.change_language).setIcon(R.drawable.ic_menu_start_conversation)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    menu.add(0, MENU_PREFERENCES, 0, R.string.general_preferences).setIcon(R.drawable.ic_menu_preferences)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    return true;
}

From source file:com.kll.collect.android.activities.FormEntryActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Collect.getInstance().getActivityLogger().logInstanceAction(this, "onCreateOptionsMenu", "show");
    super.onCreateOptionsMenu(menu);

    CompatibilityUtils.setShowAsAction(/*from  ww  w. j  ava 2  s .  com*/
            menu.add(0, MENU_SAVE, 0, R.string.save_all_answers).setIcon(android.R.drawable.ic_menu_save),
            MenuItem.SHOW_AS_ACTION_IF_ROOM);

    CompatibilityUtils.setShowAsAction(
            menu.add(0, MENU_HIERARCHY_VIEW, 0, R.string.view_hierarchy).setIcon(R.drawable.ic_menu_goto),
            MenuItem.SHOW_AS_ACTION_IF_ROOM);

    CompatibilityUtils.setShowAsAction(menu.add(0, MENU_LANGUAGES, 0, R.string.change_language)
            .setIcon(R.drawable.ic_menu_start_conversation), MenuItem.SHOW_AS_ACTION_NEVER);

    CompatibilityUtils.setShowAsAction(menu.add(0, MENU_PREFERENCES, 0, R.string.general_preferences)
            .setIcon(R.drawable.ic_menu_preferences), MenuItem.SHOW_AS_ACTION_NEVER);
    return true;
}

From source file:com.android.settings.applications.CanBeOnSdCardChecker.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    mOptionsMenu = menu;/*from  w  w  w. ja  v  a2s  .  c  om*/
    // note: icons removed for now because the cause the new action
    // bar UI to be very confusing.
    menu.add(0, SORT_ORDER_ALPHA, 1, R.string.sort_order_alpha)
            //.setIcon(android.R.drawable.ic_menu_sort_alphabetically)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(0, SORT_ORDER_SIZE, 2, R.string.sort_order_size)
            //.setIcon(android.R.drawable.ic_menu_sort_by_size)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(0, SHOW_RUNNING_SERVICES, 3, R.string.show_running_services)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    menu.add(0, SHOW_BACKGROUND_PROCESSES, 3, R.string.show_background_processes)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    menu.add(0, RESET_APP_PREFERENCES, 4, R.string.reset_app_preferences)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    if (!Utils.isRestrictedProfile(getActivity())) {
        menu.add(0, SHOW_PROTECTED_APPS, 5, R.string.protected_apps)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }
    updateOptionsMenu();
}

From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java

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

    int showOption = MenuItem.SHOW_AS_ACTION_IF_ROOM;
    MenuItem item;//  w ww .j  ava  2s.  co  m
    if (currentFragment != ScreenList.WEBKIT) {
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayOptions(ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE);
        actionBar.show();

        item = menu.add(Menu.NONE, MENU_FILL_FORM, Menu.NONE, getString(R.string.enter_data_button));
        item.setIcon(R.drawable.ic_action_collections_collection).setShowAsAction(showOption);

        // Using a file for this work now
        String get = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_GET_BLANK);
        if (get.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_PULL_FORMS, Menu.NONE, getString(R.string.get_forms));
            item.setIcon(R.drawable.ic_action_av_download).setShowAsAction(showOption);

            item = menu.add(Menu.NONE, MENU_CLOUD_FORMS, Menu.NONE, getString(R.string.get_forms));
            item.setIcon(R.drawable.ic_action_cloud).setShowAsAction(showOption);
        }

        String send = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_SEND_FINALIZED);
        if (send.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_PUSH_FORMS, Menu.NONE, getString(R.string.send_data));
            item.setIcon(R.drawable.ic_action_av_upload).setShowAsAction(showOption);
        }

        String manage = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_MANAGE_FORMS);
        if (manage.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_MANAGE_FORMS, Menu.NONE, getString(R.string.manage_files));
            item.setIcon(R.drawable.trash).setShowAsAction(showOption);
        }

        String settings = PropertiesSingleton.getProperty(appName,
                AdminPreferencesActivity.KEY_ACCESS_SETTINGS);
        if (settings.equalsIgnoreCase("true")) {
            item = menu.add(Menu.NONE, MENU_PREFERENCES, Menu.NONE, getString(R.string.general_preferences));
            item.setIcon(R.drawable.ic_menu_preferences).setShowAsAction(showOption);
        }
        item = menu.add(Menu.NONE, MENU_ADMIN_PREFERENCES, Menu.NONE, getString(R.string.admin_preferences));
        item.setIcon(R.drawable.ic_action_device_access_accounts).setShowAsAction(showOption);

        item = menu.add(Menu.NONE, MENU_ABOUT, Menu.NONE, getString(R.string.about));
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    } else {
        ActionBar actionBar = getActionBar();
        actionBar.hide();
    }

    return true;
}

From source file:org.kiwix.kiwixmobile.KiwixMobileActivity.java

@Override
public void onResume() {
    super.onResume();
    invalidateOptionsMenu();/*w  ww  .j ava2s.  c  o  m*/
    if (wasHideToolbar != isHideToolbar) {
        wasHideToolbar = isHideToolbar;

        List<KiwixWebView> newWebViews = new ArrayList<>();
        for (int i = 0; i < mWebViews.size(); i++) {
            KiwixWebView newView = getWebView(mWebViews.get(i).getUrl());
            newWebViews.add(i, newView);
        }
        mWebViews = newWebViews;
        selectTab(currentWebViewIndex);
    }
    if (refresh) {
        refresh = false;
        recreate();
    }
    if (menu != null) {
        refreshBookmarkSymbol(menu);
    }
    if (getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE) {
        if (menu != null) {
            menu.getItem(4).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        }
    } else {
        if (menu != null) {
            menu.getItem(4).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }
    }

    if (settings.getBoolean(KiwixSettingsActivity.PREF_BOTTOM_TOOLBAR, false)) {
        pageBottomTabLayout.setVisibility(View.VISIBLE);
    } else {
        pageBottomTabLayout.setVisibility(View.GONE);
    }

    Intent intent = getIntent();
    if (intent.getAction() != null) {

        if (intent.getAction().equals(Intent.ACTION_PROCESS_TEXT)) {
            final String zimFile = ZimContentProvider.getZimFile();
            saveTabStates();
            Intent i = new Intent(KiwixMobileActivity.this, SearchActivity.class);
            i.putExtra("zimFile", zimFile);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                i.putExtra(Intent.EXTRA_PROCESS_TEXT, intent.getStringExtra(Intent.EXTRA_PROCESS_TEXT));
            }
            intent.setAction("");
            startActivityForResult(i, REQUEST_FILE_SEARCH);
        } else if (intent.getAction().equals(KiwixSearchWidget.TEXT_CLICKED)) {
            intent.setAction("");
            goToSearch(false);
        } else if (intent.getAction().equals(KiwixSearchWidget.STAR_CLICKED)) {
            intent.setAction("");
            goToBookmarks();
        } else if (intent.getAction().equals(KiwixSearchWidget.MIC_CLICKED)) {
            intent.setAction("");
            goToSearch(true);
        }

    }
    updateWidgets(this);
}