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:com.mifos.mifosxdroid.online.collectionsheet.CollectionSheetFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {

    menu.clear();/*from   www  .  j a  v a  2 s.  c  o  m*/

    MenuItem mItemSearch = menu.add(Menu.NONE, MENU_ITEM_SEARCH, Menu.NONE, getString(R.string.search));
    //        mItemSearch.setIcon(new IconDrawable(getActivity(), MaterialIcons.md_search)
    //                .colorRes(Color.WHITE)
    //                .actionBarSize());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mItemSearch.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    MenuItem mItemRefresh = menu.add(Menu.NONE, MENU_ITEM_REFRESH, Menu.NONE, getString(R.string.refresh));
    mItemRefresh.setIcon(
            new IconDrawable(getActivity(), MaterialIcons.md_refresh).colorRes(R.color.white).actionBarSize());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mItemRefresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    MenuItem mItemSave = menu.add(Menu.NONE, MENU_ITEM_SAVE, Menu.NONE, getString(R.string.save));
    mItemSave.setIcon(
            new IconDrawable(getActivity(), MaterialIcons.md_save).colorRes(R.color.white).actionBarSize());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mItemSave.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    super.onPrepareOptionsMenu(menu);

}

From source file:com.example.android.pantry.scanner.BarcodeScannerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem menuItem;/*from   w  w  w .  ja v  a  2 s .  c o m*/

    if (mFlash) {
        menuItem = menu.add(Menu.NONE, R.id.menu_flash, 0, R.string.flash_on);
    } else {
        menuItem = menu.add(Menu.NONE, R.id.menu_flash, 0, R.string.flash_off);
    }
    MenuItemCompat.setShowAsAction(menuItem, MenuItem.SHOW_AS_ACTION_NEVER);

    if (mAutoFocus) {
        menuItem = menu.add(Menu.NONE, R.id.menu_auto_focus, 0, R.string.auto_focus_on);
    } else {
        menuItem = menu.add(Menu.NONE, R.id.menu_auto_focus, 0, R.string.auto_focus_off);
    }
    MenuItemCompat.setShowAsAction(menuItem, MenuItem.SHOW_AS_ACTION_NEVER);

    menuItem = menu.add(Menu.NONE, R.id.menu_formats, 0, R.string.formats);
    MenuItemCompat.setShowAsAction(menuItem, MenuItem.SHOW_AS_ACTION_NEVER);

    menuItem = menu.add(Menu.NONE, R.id.menu_camera_selector, 0, R.string.select_camera);
    MenuItemCompat.setShowAsAction(menuItem, MenuItem.SHOW_AS_ACTION_NEVER);

    return super.onCreateOptionsMenu(menu);
}

From source file:com.arantius.tivocommander.Utils.java

@SuppressLint("InlinedApi")
public final static void createShortOptionsMenu(Menu menu, Activity activity) {
    addToMenu(menu, activity, R.id.menu_item_settings, R.drawable.icon_cog, "Settings",
            MenuItem.SHOW_AS_ACTION_NEVER);
    addToMenu(menu, activity, R.id.menu_item_help, R.drawable.icon_help, "Help", MenuItem.SHOW_AS_ACTION_NEVER);
    addToMenu(menu, activity, R.id.menu_item_about, R.drawable.icon_info, "About",
            MenuItem.SHOW_AS_ACTION_NEVER);
}

From source file:com.jrummyapps.busybox.fragments.ScriptsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.add(0, R.id.action_settings, 0, R.string.settings).setIcon(R.drawable.ic_settings_white_24dp)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.add(0, R.id.action_info, 0, R.string.about).setIcon(R.drawable.ic_information_white_24dp)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.softminds.matrixcalculator.base_activities.ViewCreatedMatrix.java

public boolean onOptionsItemSelected(MenuItem item) {
    EditFragment editFragment = new EditFragment();
    int index = getIntent().getIntExtra("INDEX", -1);
    switch (item.getItemId()) {
    case R.id.EditEntered:

        Bundle bundle = new Bundle();
        bundle.putInt("INDEX", getIntent().getIntExtra("INDEX", -1));
        editFragment.setArguments(bundle);
        FragmentTransaction FragmentTR = getSupportFragmentManager().beginTransaction();
        FragmentTR.replace(R.id.FragmentContainer, editFragment, "FRAGMENTEDIT");
        FragmentTR.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        FragmentTR.commit();//  w  w w. j  a v a 2 s.  c  om
        ((GlobalValues) getApplication()).current_editing = ((GlobalValues) getApplication()).GetCompleteList()
                .get(getIntent().getIntExtra("INDEX", -1));
        ActionMenu.findItem(R.id.EditEntered).setVisible(false);
        ActionMenu.findItem(R.id.OrderChange).setVisible(false);
        ActionMenu.findItem(R.id.DeleteCreated).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        ActionMenu.findItem(R.id.DeleteCreated).setTitle(R.string.Delete2);
        ActionMenu.findItem(R.id.ConfirmChanges).setVisible(true);
        ActionMenu.findItem(R.id.RevertChanges).setVisible(true);
        return true;
    case R.id.DeleteCreated:
        if (index != (-1)) {
            ((GlobalValues) getApplication()).GetCompleteList().remove(index);
            ((GlobalValues) getApplication()).matrixAdapter.notifyDataSetChanged();
            Toast.makeText(getApplicationContext(), R.string.Deleted, Toast.LENGTH_SHORT).show();
            finish();
        }
        return true;
    case R.id.OrderChange:
        Intent intent4 = new Intent(getApplicationContext(), OrderChanger.class);
        intent4.putExtra("INDEX_OF_SELECTED_MATRIX", index);
        startActivityForResult(intent4, ChangedOrder);
        return true;
    case R.id.Rename:
        Intent intent = new Intent(getApplicationContext(), RenameCreated.class);
        intent.putExtra("TITLE_OF_THIS_FORMATION",
                ((GlobalValues) getApplication()).GetCompleteList().get(index).getName());
        startActivityForResult(intent, 100);
        return true;
    case R.id.RevertChanges:
        EditFragment editFragment1 = ((EditFragment) getSupportFragmentManager()
                .findFragmentByTag("FRAGMENTEDIT"));
        editFragment1.RevertChanges();
        Toast.makeText(getApplicationContext(), R.string.RevertSuccess, Toast.LENGTH_SHORT).show();
        finish();
        return true;
    case R.id.ConfirmChanges:
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.detach(editFragment);
        transaction.commit();
        finish();
        Toast.makeText(getApplicationContext(), R.string.ConfirmSuccess, Toast.LENGTH_SHORT).show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.facebook.react.views.toolbar.ReactToolbarManager.java

@Nullable
@Override// ww  w . j  a  v  a  2  s .c  o  m
public Map<String, Object> getExportedViewConstants() {
    return MapBuilder.<String, Object>of("ShowAsAction", MapBuilder.of("never", MenuItem.SHOW_AS_ACTION_NEVER,
            "always", MenuItem.SHOW_AS_ACTION_ALWAYS, "ifRoom", MenuItem.SHOW_AS_ACTION_IF_ROOM));
}

From source file:com.numenta.taurus.TaurusBaseActivity.java

@SuppressLint("AlwaysShowAction")
private void updateRefresh() {
    if (_refresh != null) {
        if (TaurusApplication.isRefreshing()) {
            _refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            _refresh.setActionView(_refreshView);

            // Calculate the interval since last connection to the server
            final SharedPreferences pref = PreferenceManager
                    .getDefaultSharedPreferences(getApplicationContext());
            final long now = System.currentTimeMillis();
            final long lastConnected = pref.getLong(PREF_LAST_CONNECTED_TIME, now);
            final long interval = now - lastConnected;

            // Notify the user if the last time we connected was more than one hour ago
            if (interval > DataUtils.MILLIS_PER_HOUR) {
                final long hour = interval / DataUtils.MILLIS_PER_HOUR;
                final long minutes = (interval % DataUtils.MILLIS_PER_HOUR) / DataUtils.MILLIS_PER_MINUTE;
                if (hour > 0) {
                    String title;
                    // Format message: "X hours ago" or "X hours and Y minutes ago"
                    if (minutes > 0) {
                        title = getApplicationContext().getString(R.string.loading_metrics_title_hours_minutes,
                                hour, minutes);
                    } else {
                        title = getApplicationContext().getString(R.string.loading_metrics_title_hours, hour);
                    }/*  www .  j  a  v  a  2s.c  o  m*/
                    Toast.makeText(this, title, Toast.LENGTH_LONG).show();
                }
            }
        } else {
            // Check if we have an error message
            String refreshError = TaurusApplication.getLastError();
            if (refreshError == null) {
                _refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
                // Restore refresh icon
                _refresh.setIcon(R.drawable.ic_action_refresh);
            } else {
                _refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
                // Show error icon
                _refresh.setIcon(R.drawable.ic_action_connection_error);
            }
            _refresh.setActionView(null);
        }
    }
}

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

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.add(Menu.NONE, R.id.refresh, Menu.NONE, R.string.refresh)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); // prefer actionbar refresh
    menu.add(Menu.NONE, R.id.action_back_top, Menu.NONE, getString(R.string.back_to_top))
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    // ??/*from   w w  w . ja  va2  s.  c  o  m*/
    MenuItem search = menu.add(android.R.string.search_go);
    search.setIcon(R.drawable.ic_title_search_default);
    search.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    mSearchView = VividSearchView.getSearchView(getActivity());
    mSearchView.setOnQueryTextListener(this);
    mSearchView.setOnCloseListener(this);
    search.setActionView(mSearchView);
}

From source file:net.potterpcs.recipebook.RecipeBookActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.mainmenu, menu);

    // Set up the action bar, if we have one. (Pre-Honeycomb devices don't) 
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.menunew),
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.menushowall),
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.menuhelp), MenuItem.SHOW_AS_ACTION_IF_ROOM);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.menuexport), MenuItem.SHOW_AS_ACTION_NEVER);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.menuprefs), MenuItem.SHOW_AS_ACTION_IF_ROOM);

    hideShowAllItem(menu);/*  w w  w . ja  v a 2 s.co m*/
    setSortOptions(menu);
    return true;
}

From source file:ca.rmen.android.palidamuerte.app.poem.detail.PoemDetailActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Log.v(TAG, "onCreateOptionsMenu");
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_poem, menu);
    menu.findItem(R.id.action_about).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.action_share).getActionProvider();
    if (mPoemPagerAdapter != null) {
        long poemId = mPoemPagerAdapter.getPoemIdAt(mViewPager.getCurrentItem());
        Poems.updateShareIntent(mShareActionProvider, PoemDetailActivity.this, poemId);
    }/*from   www. j ava 2  s  . c  om*/
    return true;
}