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:org.alfresco.mobile.android.application.fragments.sync.SyncCursorAdapter.java

public void getMenu(Menu menu, Integer statut, boolean rootSynced) {
    MenuItem mi;/*from w w w .j  a v  a  2  s  . co m*/

    switch (statut) {
    case SyncContentStatus.STATUS_HIDDEN:
        mi = menu.add(Menu.NONE, R.id.menu_action_favorite_group, Menu.FIRST, R.string.favorite);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        break;
    case SyncContentStatus.STATUS_FAILED:
    case SyncContentStatus.STATUS_REQUEST_USER:
        mi = menu.add(Menu.NONE, R.id.menu_sync_resolution, Menu.FIRST, R.string.sync_resolve_conflict);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        break;
    default:
        if (rootSynced) {
            mi = menu.add(Menu.NONE, R.id.menu_action_sync_group_unsync, Menu.FIRST, R.string.unsync);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }
        break;
    }
}

From source file:org.catnut.plugin.zhihu.ZhihuItemFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.add(Menu.NONE, ACTION_VIEW_ALL_ON_WEB, Menu.NONE, getString(R.string.view_all_answer))
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(Menu.NONE, ACTION_VIEW_ON_WEB, Menu.NONE, getString(R.string.zhihu_view_on_web))
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
}

From source file:com.android.mms.quickmessage.QuickMessagePopup.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    menu.clear();/*from   w w  w .java2 s  .  c o m*/
    // Templates menu item, if there are defined templates
    if (mNumTemplates > 0) {
        menu.add(0, MENU_ADD_TEMPLATE, 0, R.string.template_insert).setIcon(android.R.drawable.ic_menu_add)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    // Add to Blacklist item (if enabled) and we are running on CyanogenMod
    // This allows the app to be run on non-blacklist enabled roms (including Stock)
    if (MessageUtils.isCyanogenMod(this)) {
        if (BlacklistUtils.isBlacklistEnabled(this)) {
            menu.add(0, MENU_ADD_TO_BLACKLIST, 0, R.string.add_to_blacklist)
                    .setIcon(R.drawable.ic_block_message_holo_dark)
                    .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }
    }
}

From source file:gov.cdc.epiinfo.RecordList.java

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

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView = new SearchView(this);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override/*ww w.jav a2s  .co  m*/
        public boolean onQueryTextSubmit(String searchTerm) {

            try {
                mDbHelper.fetchTopOne();

                String query = BuildQuery(searchTerm);

                String fieldName1;
                String fieldName2;
                String fieldName3;
                String[] from = new String[1];
                int[] to = new int[1];

                if (formMetadata.DataFields.size() > 2) {

                    fieldName1 = formMetadata.DataFields.get(0).getName();
                    fieldName2 = formMetadata.DataFields.get(1).getName();
                    fieldName3 = formMetadata.DataFields.get(2).getName();
                    mNotesCursor = mDbHelper.fetchWhere(fieldName1, fieldName2, fieldName3, query);
                    from = new String[] { "_id", "columnName1", fieldName1, "columnName2", fieldName2,
                            "columnName3", fieldName3, "_syncStatus" };
                    to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.header3, R.id.text3,
                            R.id.header4, R.id.text4, R.id.hiddenText };
                } else if (formMetadata.DataFields.size() == 2) {
                    fieldName1 = formMetadata.DataFields.get(0).getName();
                    fieldName2 = formMetadata.DataFields.get(1).getName();
                    mNotesCursor = mDbHelper.fetchWhere(fieldName1, fieldName2, query);
                    from = new String[] { "_id", "columnName1", fieldName1, "columnName2", fieldName2,
                            "_syncStatus" };
                    to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.header3, R.id.text3,
                            R.id.hiddenText };
                } else if (formMetadata.DataFields.size() == 1) {
                    fieldName1 = formMetadata.DataFields.get(0).getName();
                    mNotesCursor = mDbHelper.fetchWhere(fieldName1, query);
                    from = new String[] { "_id", "columnName1", fieldName1, "_syncStatus" };
                    to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.hiddenText };
                }

                startManagingCursor(mNotesCursor);
                CustomListAdapter notes = new CustomListAdapter(self, R.layout.line_list_row, mNotesCursor,
                        from, to);
                lineListFragment.setListAdapter(notes);

            } catch (Exception ex) {
                fillData();
            }

            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {

            if (newText.equals("")) {
                fillData();
            }

            return false;
        }
    });

    mnuSearch = menu.add(0, SEARCH_ID, 0, R.string.menu_search);
    mnuSearch.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    mnuSearch.setActionView(searchView);
    mnuSearch.setIcon(gov.cdc.epiinfo.R.drawable.action_search);

    MenuItem mnuQR = menu.add(0, QR_ID, 1, R.string.menu_barcode);
    mnuQR.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    mnuQR.setIcon(gov.cdc.epiinfo.R.drawable.qrcode_scan);

    MenuItem mnuCloud = menu.add(0, CLOUD_ID, 2, R.string.menu_cloud_sync);
    mnuCloud.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    MenuItem mnuSync = menu.add(0, SYNC_ID, 3, R.string.menu_sync_file);
    mnuSync.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    MenuItem mnuDeleteAll = menu.add(0, DELETE_ALL_ID, 4, R.string.menu_delete_all);
    mnuDeleteAll.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    if (fkeyGuid == null || fkeyGuid.length() == 0) {
        mnuSetDefault = menu.add(0, SET_DEFAULT_ID, 5, R.string.set_default_form);
        mnuSetDefault.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

        mnuExitDefault = menu.add(0, EXIT_DEFAULT_MODE_ID, 5, R.string.exit_default_form);
        mnuExitDefault.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

        if (AppManager.getDefaultForm().equals("")) {
            mnuSetDefault.setVisible(true);
            mnuExitDefault.setVisible(false);
        } else {
            mnuSetDefault.setVisible(false);
            mnuExitDefault.setVisible(true);
        }
    }

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    if (sharedPref.getString("cloud_service", "").equals("Box")) {
        mnuBoxSignin = menu.add(0, BOX_SIGNIN_ID, 6, R.string.box_signin);
        mnuBoxSignin.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

        mnuBoxSignout = menu.add(0, BOX_SIGNOUT_ID, 6, R.string.box_signout);
        mnuBoxSignout.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

        if (BoxClient.isAuthenticated(this)) {
            mnuBoxSignout.setVisible(true);
            mnuBoxSignin.setVisible(false);
        } else {
            mnuBoxSignout.setVisible(false);
            mnuBoxSignin.setVisible(true);
        }
    }

    MenuItem mnuHelp = menu.add(1, HELP_ID, 7, R.string.menu_help);
    mnuHelp.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    return true;
}

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

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

    menu.add(0, MENU_ABOUT, 0, R.string.about_preferences).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);

    menu.add(0, MENU_ADMIN, 0, R.string.admin_preferences).setIcon(R.drawable.ic_menu_login)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    return true;// ww w.  ja  v a2s  . c om
}

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

public void onCreateGlobalOptionsMenu(final Context context, final Menu menu) {
    final MenuItem about = menu.add(getString(R.string.about));
    MenuItemCompat.setShowAsAction(about, MenuItem.SHOW_AS_ACTION_NEVER);
    about.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(final MenuItem menuItem) {
            final Intent intent = new Intent(getApplicationContext(), AboutActivity.class);
            context.startActivity(intent);
            return false;
        }/* w  ww .  j  av a  2  s. co  m*/
    });

    final MenuItem help = menu.add(getString(R.string.help));
    MenuItemCompat.setShowAsAction(help, MenuItem.SHOW_AS_ACTION_NEVER);
    help.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(final MenuItem menuItem) {
            context.startActivity(HtmlDisplayActivity.getHelpLaunchIntent(getApplicationContext()));
            return false;
        }
    });

    final MenuItem preferences = menu.add(getString(R.string.settings));
    MenuItemCompat.setShowAsAction(preferences, MenuItem.SHOW_AS_ACTION_NEVER);
    preferences.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(final MenuItem menuItem) {
            PreferenceActivity.prefsMightHaveChanged = true;
            final Intent intent = new Intent(getApplicationContext(), PreferenceActivity.class);
            context.startActivity(intent);
            return false;
        }
    });

    final MenuItem reportIssue = menu.add(getString(R.string.reportIssue));
    MenuItemCompat.setShowAsAction(reportIssue, MenuItem.SHOW_AS_ACTION_NEVER);
    reportIssue.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(final MenuItem menuItem) {
            final Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("http://github.com/rdoeffinger/Dictionary/issues"));
            context.startActivity(intent);
            return false;
        }
    });
}

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

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    final MenuItem sort = menu.add(getString(R.string.sortDicts));
    MenuItemCompat.setShowAsAction(sort, MenuItem.SHOW_AS_ACTION_NEVER);
    sort.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        public boolean onMenuItemClick(final MenuItem menuItem) {
            application.sortDictionaries();
            setMyListAdapater();//from   www.j  a va  2  s . co  m
            return true;
        }
    });

    application.onCreateGlobalOptionsMenu(this, menu);
    return true;
}

From source file:org.alfresco.mobile.android.application.fragments.workflow.task.TaskDetailsFragment.java

public void getMenu(Menu menu) {
    MenuItem mi;/*w  w w.  ja  v  a  2  s.c o  m*/

    String processDefinitionKey = WorkflowUtils.getKeyFromProcessDefinitionId(processDefinitionId);

    if (endedAt == null && processDefinitionKey.startsWith(WorkflowModel.KEY_PREFIX_ACTIVITI)) {
        mi = menu.add(Menu.NONE, R.id.menu_process_details, Menu.FIRST, R.string.process_diagram);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    mi = menu.add(Menu.NONE, R.id.menu_process_history, Menu.FIRST + 1, R.string.tasks_history);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    if (currentTask == null || endedAt != null) {
        return;
    }

    // unclaim : I unassign myself (generally created by a pooled process)
    if (currentTask.getAssigneeIdentifier() != null
            && WorkflowModel.FAMILY_PROCESS_POOLED_REVIEW.contains(processDefinitionKey)) {
        mi = menu.add(Menu.NONE, R.id.menu_task_unclaim, Menu.FIRST + 2, R.string.task_unclaim);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    }
    // reassign : I have a task and I decide I dont want to be responsible
    // anymore of this task so I reassign to a specific person
    else if (currentTask.getAssigneeIdentifier() != null) {
        mi = menu.add(Menu.NONE, R.id.menu_task_reassign, Menu.FIRST + 3, R.string.task_reassign);
        mi.setIcon(R.drawable.ic_reassign);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
    // claim : I assign to me an unassigned task (created by a pooled
    // process)
    else if ((currentTask.getAssigneeIdentifier() == null
            && WorkflowModel.FAMILY_PROCESS_POOLED_REVIEW.contains(processDefinitionKey))
            || "unclaimed".equals(state)) {
        mi = menu.add(Menu.NONE, R.id.menu_task_claim, Menu.FIRST + 4, R.string.task_claim);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    }
}

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

public void getMenu(Menu menu, Node node) {
    MenuItem mi;/*from ww w  . j  ava2 s  .  c o  m*/

    mi = menu.add(Menu.NONE, R.id.menu_node_details, Menu.FIRST, R.string.action_view_properties);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    if (ConfigurableActionHelper.isVisible(getActivity(), SessionUtils.getAccount(getActivity()),
            SessionUtils.getSession(getActivity()), node, ConfigurableActionHelper.ACTION_NODE_EDIT)) {
        mi = menu.add(Menu.NONE, R.id.menu_action_edit, Menu.FIRST + 50, R.string.action_edit_properties);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    if (ConfigurableActionHelper.isVisible(getActivity(), SessionUtils.getAccount(getActivity()),
            SessionUtils.getSession(getActivity()), node, ConfigurableActionHelper.ACTION_NODE_DELETE)) {
        mi = menu.add(Menu.NONE, R.id.menu_action_delete_folder, Menu.FIRST + 1000, R.string.delete);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

}

From source file:de.badaix.snapcast.MainActivity.java

public void updateMenuItems(final boolean connected) {
    this.runOnUiThread(new Runnable() {
        @Override/*from  w  w w  .j  a  v  a 2  s.c o m*/
        public void run() {
            if (connected) {
                if (miSettings != null)
                    miSettings.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
                if (miStartStop != null)
                    miStartStop.setVisible(true);
                //                    if (miRefresh != null)
                //                        miRefresh.setVisible(true);
            } else {
                if (miSettings != null)
                    miSettings.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
                if (miStartStop != null)
                    miStartStop.setVisible(false);
                //                    if (miRefresh != null)
                //                        miRefresh.setVisible(false);
            }
        }
    });
}