Example usage for android.view MenuItem SHOW_AS_ACTION_ALWAYS

List of usage examples for android.view MenuItem SHOW_AS_ACTION_ALWAYS

Introduction

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

Prototype

int SHOW_AS_ACTION_ALWAYS

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

Click Source Link

Document

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

Usage

From source file:ro.expectations.expenses.ui.categories.EditCategoryFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add(Menu.NONE, R.id.action_save, Menu.NONE, R.string.action_save);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    item.setIcon(DrawableHelper.tint(getActivity(), R.drawable.ic_done_black_24dp, R.color.colorWhite));
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.android.mms.ui.SelectRecipientsList.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Load the required preference values
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mMobileOnly = sharedPreferences.getBoolean(PREF_MOBILE_NUMBERS_ONLY, true);

    menu.add(0, MENU_DONE, 0, R.string.menu_done).setIcon(R.drawable.ic_menu_done)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT)
            .setVisible(false);// www .  j a v a 2  s .  c  o  m

    menu.add(0, MENU_MOBILE, 0, R.string.menu_mobile).setCheckable(true).setChecked(mMobileOnly)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    boolean useAltNameOrdering = mContactsPreferences
            .getSortOrder() == ContactsPreferences.SORT_ORDER_ALTERNATIVE;
    int nameOrderItemTitleRes = useAltNameOrdering ? R.string.menu_order_by_given_name
            : R.string.menu_order_by_last_name;

    menu.add(0, MENU_NAME_ORDER, 0, nameOrderItemTitleRes)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    return super.onCreateOptionsMenu(menu);
}

From source file:org.catnut.fragment.OAuthFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem refresh = menu.add(Menu.NONE, R.id.refresh, Menu.NONE, getString(R.string.refresh));
    refresh.setIcon(R.drawable.ic_action_retry);
    refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}

From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActionMode.java

private void getMenu(Menu menu) {
    MenuItem mi;//from ww w .ja v a  2  s  . co m
    menu.clear();

    mi = menu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_DELETE_ID,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS, R.string.editor_tools_settings);
    mi.setIcon(R.drawable.ic_delete);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // GROUP MENU
    if (selectedSpenObjects.size() > 1) {
        SubMenu groupSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST,
                R.string.editor_group_menu);
        groupSubMenu.setIcon(R.drawable.ic_group);
        groupSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

        mi = groupSubMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_GROUP_ID,
                Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_GROUP_ID, R.string.editor_group);

        mi = groupSubMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_UNGROUP_ID,
                Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_UNGROUP_ID, R.string.editor_ungroup);

        mi.setEnabled(false);
        for (SpenObjectBase obj : selectedSpenObjects) {
            if (obj.getType() == SpenObjectBase.TYPE_CONTAINER) {
                mi.setEnabled(true);
                break;
            }
        }
    }

    // UP MENU
    SubMenu upMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST,
            R.string.editor_front_menu);
    upMenu.setIcon(R.drawable.ic_move_up);
    upMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    mi = upMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_FORWARD_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_FORWARD_ID, R.string.editor_forward);

    mi = upMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_TOP_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_TOP_ID, R.string.editor_front);

    // DOWN MENU
    SubMenu downMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST,
            R.string.editor_back_menu);
    downMenu.setIcon(R.drawable.ic_move_down);
    downMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    mi = downMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BACKWARD_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BACKWARD_ID, R.string.editor_backward);

    mi = downMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BOTTOM_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BOTTOM_ID, R.string.editor_back);
}

From source file:com.getchute.android.photopickerplus.ui.activity.ServicesActivity.java

@SuppressLint("NewApi")
@Override/*from  w  ww  . j  ava 2  s. c om*/
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    if (PhotoPicker.getInstance().hasLogoutOption()) {
        MenuItem item = menu.add(0, LOGOUT_ITEM, 0, R.string.button_navigation_services_logout);
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }
    return true;

}

From source file:org.orange.querysystem.PostsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    mRefreshMenuItem = menu.add(0, 1, 1, R.string.refresh).setIcon(R.drawable.ic_action_refresh);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mRefreshMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        if (mWebUpdaterToDB != null && mWebUpdaterToDB.isUpdating())
            startRefreshAnimation();/*ww w  . j  av  a  2  s .  c om*/
    }
    menu.add(0, 2, 2, R.string.settings);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.vadimfrolov.duorem.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem miAdd = (MenuItem) menu.findItem(R.id.action_add_host);
    MenuItem miEdit = (MenuItem) menu.findItem(R.id.action_edit_host);
    MenuItem miDelete = (MenuItem) menu.findItem(R.id.action_delete_host);
    boolean targetIsValid = mTarget != null
            && ((mTarget.ipAddress != null && !mTarget.ipAddress.equals(NetInfo.NOIP))
                    || (mTarget.hardwareAddress != null && !mTarget.hardwareAddress.equals(NetInfo.NOMAC)));

    if (targetIsValid) {
        miAdd.setTitle(getResources().getString(R.string.replace_host));
    } else {//from w w  w.  java  2s.co  m
        miAdd.setTitle(getResources().getString(R.string.add_host));
    }
    miEdit.setEnabled(targetIsValid);
    miDelete.setEnabled(targetIsValid);

    miEdit.setShowAsAction(targetIsValid ? MenuItem.SHOW_AS_ACTION_ALWAYS : MenuItem.SHOW_AS_ACTION_NEVER);
    miDelete.setShowAsAction(targetIsValid ? MenuItem.SHOW_AS_ACTION_ALWAYS : MenuItem.SHOW_AS_ACTION_NEVER);
    // hide replace menu item under the unfoldable menu
    miAdd.setShowAsAction(targetIsValid ? MenuItem.SHOW_AS_ACTION_NEVER : MenuItem.SHOW_AS_ACTION_ALWAYS);

    return super.onPrepareOptionsMenu(menu);
}

From source file:org.protocoder.fragments.EditorFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    this.menu = menu;
    menu.clear();/*w  ww . j a  va  2  s . com*/
    menu.add(1, MENU_RUN, 0, "Run").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.add(1, MENU_SAVE, 0, "Save").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.add(1, MENU_FILES, 0, "Files").setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(1, MENU_API, 0, "API").setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.android.mms.ui.MailBoxMessageContent.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();//from  w ww . jav a2 s .  c  o m

    if (MessageUtils.hasIccCard()) {
        menu.add(0, MENU_CALL_RECIPIENT, 0, R.string.menu_call).setIcon(R.drawable.ic_menu_call)
                .setTitle(R.string.menu_call).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }

    if (mMsgType == Sms.MESSAGE_TYPE_INBOX) {
        menu.add(0, MENU_REPLY, 0, R.string.menu_reply);
        menu.add(0, MENU_FORWARD, 0, R.string.menu_forward);
        menu.add(0, MENU_DELETE, 0, R.string.delete);
    } else if (mMsgType == Sms.MESSAGE_TYPE_FAILED || mMsgType == Sms.MESSAGE_TYPE_OUTBOX) {
        menu.add(0, MENU_FORWARD, 0, R.string.menu_forward);
        menu.add(0, MENU_RESEND, 0, R.string.menu_resend);
        menu.add(0, MENU_DELETE, 0, R.string.delete);
    } else if (mMsgType == Sms.MESSAGE_TYPE_SENT) {
        menu.add(0, MENU_FORWARD, 0, R.string.menu_forward);
        menu.add(0, MENU_RESEND, 0, R.string.menu_resend);
        menu.add(0, MENU_DELETE, 0, R.string.delete);
    } else if (mMsgType == Sms.MESSAGE_TYPE_QUEUED) {
        menu.add(0, MENU_FORWARD, 0, R.string.menu_forward);
        menu.add(0, MENU_DELETE, 0, R.string.delete);
    }

    if (isLockMessage()) {
        menu.add(0, MENU_LOCK, 0, R.string.menu_unlock);
    } else {
        menu.add(0, MENU_LOCK, 0, R.string.menu_lock);
    }

    if (!Contact.get(mMsgFrom, false).existsInDatabase()) {
        menu.add(0, MENU_SAVE_TO_CONTACT, 0, R.string.menu_add_to_contacts_cm);
    }

    return true;
}

From source file:com.franmontiel.fullscreendialog.FullScreenDialogFragment.java

private void initToolbar(View view) {
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);

    Drawable closeDrawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_close);
    tintToolbarHomeButton(toolbar, closeDrawable);

    toolbar.setNavigationIcon(closeDrawable);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override/*from w w w.  j av  a  2 s .c  o  m*/
        public void onClick(View v) {
            onDiscardButtonClick();
        }
    });

    toolbar.setTitle(title);

    Menu menu = toolbar.getMenu();

    final int menuItemTitleId = 1;
    itemConfirmButton = menu.add(0, menuItemTitleId, 0, this.positiveButton);
    itemConfirmButton.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    itemConfirmButton.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == menuItemTitleId) {
                onConfirmButtonClick();
                return true;
            } else
                return false;
        }
    });
}