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:me.piebridge.prevent.ui.PreventActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.clear();/*  w ww .  ja  v  a 2s. com*/
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        preventMenu = menu.add(Menu.NONE, R.string.prevent, Menu.NONE, R.string.prevent);
        preventMenu.setIcon(R.drawable.ic_menu_block);
        preventMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        preventMenu.setVisible(false);
        removeMenu = menu.add(Menu.NONE, R.string.remove, Menu.NONE, R.string.remove);
        removeMenu.setIcon(R.drawable.ic_menu_star);
        removeMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        removeMenu.setVisible(false);
    }
    menu.add(Menu.NONE, R.string.switch_theme, Menu.NONE, R.string.switch_theme);
    menu.add(Menu.NONE, R.string.system_log, Menu.NONE, R.string.system_log);
    menu.add(Menu.NONE, R.string.advanced_settings, Menu.NONE, R.string.advanced_settings);
    menu.add(Menu.NONE, R.string.user_guide, Menu.NONE, R.string.user_guide);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.getchute.android.photopickerplus.ui.fragment.FragmentRoot.java

@SuppressLint("NewApi")
@Override/*  w w w  . j  a  v  a 2 s  .  c o  m*/
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MenuItem menuItemUse = menu.add(0, AssetActivity.USE_ITEM, 0, R.string.button_use_media);
    menuItemUse.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}

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

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

    // Set up the action bar for devices that have it
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.editormenusave),
            MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.editormenuhelp), MenuItem.SHOW_AS_ACTION_IF_ROOM);
    return true;//from   w  w  w .ja va 2s .  c  o  m
}

From source file:tkj.android.homecontrol.mythmote.MythMote.java

/**
 * Called to create the options menu once.
 *///from   w  w w .jav a2 s .c om
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean result = super.onCreateOptionsMenu(menu);

    // create reconnect menu item
    MenuItem menuItem = menu.add(0, RECONNECT_ID, 0, R.string.reconnect_str)
            .setIcon(R.drawable.ic_menu_refresh);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }

    // create settings menu item
    menuItem = menu.add(0, SETTINGS_ID, 0, R.string.settings_menu_str)
            .setIcon(android.R.drawable.ic_menu_preferences);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    // create keyboard input menu item
    menuItem = menu.add(0, KEYBOARD_INPUT_ID, 0, R.string.keyboard_input_str)
            .setIcon(R.drawable.ic_notification_ime_default);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    // create select location menu item
    menuItem = menu.add(0, SELECTLOCATION_ID, 0, R.string.selected_location_str)
            .setIcon(R.drawable.ic_menu_home);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    //create wake on lan menu item
    menuItem = menu.add(0, SENDWOL_ID, 0, R.string.send_wol_str).setIcon(R.drawable.ic_menu_sun);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    }
    //menu.add(0, SENDWOL_RE_ID, 0, R.string.send_wol_re_str);
    //menu.add(0, SENDWOL_PJ_ID, 0, R.string.send_wol_pj_str);

    //add donate button if enabled
    if (sShowDonateMenuItem) {

    }

    // return results
    return result;
}

From source file:net.simonvt.cathode.ui.fragment.EpisodeFragment.java

private void createMenu(Toolbar toolbar) {
    Menu menu = toolbar.getMenu();
    menu.clear();/*from w ww.  jav a 2  s . co  m*/

    toolbar.inflateMenu(R.menu.activity_base);

    if (loaded) {
        if (checkedIn) {
            menu.add(0, R.id.action_checkin_cancel, 1, R.string.action_checkin_cancel)
                    .setIcon(R.drawable.ic_action_cancel).setShowAsActionFlags(
                            isTablet ? MenuItem.SHOW_AS_ACTION_NEVER : MenuItem.SHOW_AS_ACTION_ALWAYS);
        } else if (!watching) {
            menu.add(0, R.id.action_checkin, 2, R.string.action_checkin).setIcon(R.drawable.ic_action_checkin)
                    .setShowAsActionFlags(
                            isTablet ? MenuItem.SHOW_AS_ACTION_NEVER : MenuItem.SHOW_AS_ACTION_ALWAYS);
        }

        if (watched) {
            menu.add(0, R.id.action_unwatched, 3, R.string.action_unwatched);
        } else {
            menu.add(0, R.id.action_watched, 4, R.string.action_watched);
            if (inWatchlist) {
                menu.add(0, R.id.action_watchlist_remove, 5, R.string.action_watchlist_remove);
            } else {
                menu.add(0, R.id.action_watchlist_add, 6, R.string.action_watchlist_add);
            }
        }

        if (collected) {
            menu.add(0, R.id.action_collection_remove, 7, R.string.action_collection_remove);
        } else {
            menu.add(0, R.id.action_collection_add, 8, R.string.action_collection_add);
        }
    }
}

From source file:info.guardianproject.otr.app.im.app.ContactListActivity.java

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

    mSearchView = SearchViewCompat.newSearchView(this);

    if (mSearchView != null) {
        MenuItem item = menu.add("Search").setIcon(android.R.drawable.ic_menu_search)
                .setActionView(mSearchView);
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

        SearchViewCompat.setOnQueryTextListener(mSearchView, new SearchViewCompat.OnQueryTextListenerCompat() {

            @Override//from w  w w . ja va  2  s.c om
            public boolean onQueryTextChange(String newText) {
                mFilterView.doFilter(newText);
                return true;
            }

            @Override
            public boolean onQueryTextSubmit(String query) {
                mFilterView.doFilter(query);
                return true;
            }

        });

    }

    return true;
}

From source file:com.money.manager.ex.account.AccountTransactionListFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    //force show add transaction
    MenuItem itemAddTransaction = menu.findItem(R.id.menu_add_transaction_account);
    if (itemAddTransaction != null)
        itemAddTransaction.setVisible(true);
    //manage dual panel
    if (getActivity() != null && getActivity() instanceof MainActivity) {
        MainActivity activity = (MainActivity) getActivity();
        if (!activity.isDualPanel()) {
            //hide sync toolbar
            MenuItem itemSync = menu.findItem(R.id.menu_sync);
            if (itemSync != null)
                itemSync.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

            // hide menu open database
            MenuItem itemOpenDatabase = menu.findItem(R.id.menu_open_database);
            if (itemOpenDatabase != null) {
                //itemOpenDatabase.setVisible(isShownOpenDatabaseItemMenu());
                itemOpenDatabase.setShowAsAction(
                        !itemSync.isVisible() ? MenuItem.SHOW_AS_ACTION_ALWAYS : MenuItem.SHOW_AS_ACTION_NEVER);
            }//  ww w. j av  a  2s  .  c o  m

            //hide dash board
            MenuItem itemDashboard = menu.findItem(R.id.menu_dashboard);
            if (itemDashboard != null)
                itemDashboard.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }
    }

    selectCurrentPeriod(menu);
    selectCurrentStatus(menu);
}

From source file:br.com.GUI.aulas.Agenda.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.agenda_actions, menu);

    final SearchView searchView = new SearchView(getActivity().getActionBar().getThemedContext());
    searchView.setQueryHint("Search");

    menu.add(Menu.NONE, Menu.NONE, 1, "@string").setIcon(android.R.drawable.ic_menu_search)
            .setActionView(searchView)/* w  ww.j  a va 2s. co  m*/
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    searchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            if (newText.length() > 0) {
                // Search
                atualizarAgenda(newText.toString());

            } else {
                // Do something when there's no input
                atualizarAgenda(newText.toString());
            }
            return false;
        }

        @Override
        public boolean onQueryTextSubmit(String arg0) {
            // TODO Auto-generated method stub
            atualizarAgenda(arg0.toString());
            return false;
        }
    });
}

From source file:nl.sogeti.android.gpstracker.actions.Statistics.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean result = super.onCreateOptionsMenu(menu);
    MenuItem item;//from   w  ww  .j  av a2  s. c  o  m
    item = menu.add(ContextMenu.NONE, MENU_SHARE, ContextMenu.NONE, R.string.menu_shareTrack)
            .setIcon(R.drawable.ic_share_24dp).setAlphabeticShortcut('s');
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS);
    item = menu.add(ContextMenu.NONE, MENU_TRACKLIST, ContextMenu.NONE, R.string.menu_tracklist)
            .setIcon(R.drawable.ic_list_24dp).setAlphabeticShortcut('l');
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS);
    item = menu.add(ContextMenu.NONE, MENU_GRAPHTYPE, ContextMenu.NONE, R.string.menu_graphtype)
            .setIcon(R.drawable.ic_graph_24dp).setAlphabeticShortcut('t');
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_NEVER);
    return result;
}

From source file:com.ustadmobile.port.android.view.CatalogOPDSFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (mDeleteOptionAvailable && mSelectedEntries.length > 0) {
        MenuItem item = menu.add(Menu.NONE, MENUCMDID_DELETE, 1, "");
        item.setIcon(R.drawable.ic_delete_white_24dp);
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }//  w  w w  .  j  a  v  a  2s . c om

    super.onCreateOptionsMenu(menu, inflater);

}