Example usage for android.view MenuItem SHOW_AS_ACTION_IF_ROOM

List of usage examples for android.view MenuItem SHOW_AS_ACTION_IF_ROOM

Introduction

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

Prototype

int SHOW_AS_ACTION_IF_ROOM

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

Click Source Link

Document

Show this item as a button in an Action Bar if the system decides there is room for it.

Usage

From source file:com.misczak.joinmybridge.EventFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add("Search");
    item.setIcon(R.drawable.ic_search_white_24dp);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    mSearchView = new MySearchView(getActivity());
    mSearchView.setOnQueryTextListener(this);
    mSearchView.setOnCloseListener(this);
    mSearchView.setIconifiedByDefault(true);
    item.setActionView(mSearchView);//from   w ww. ja  v a2s. c  o  m
}

From source file:cz.msebera.unbound.dns.fragments.UnboundControlConsole.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.add(Menu.NONE, MENU_RUN, Menu.NONE, R.string.menu_run_command)
            .setIcon(android.R.drawable.ic_media_play).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:jp.morimotor.beaconattend.HelpActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // ?????/*  w  w w . jav a2s  .c o m*/
    MenuItem actionItem = menu.add("infoButton");

    // SHOW_AS_ACTION_IF_ROOM:???
    actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // 
    actionItem.setIcon(R.drawable.ic_info_outline_white_24dp);

    return true;
}

From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPFiltersFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MenuItem searchBtn = menu.findItem(R.id.action_search);
    searchBtn.setVisible(false);/* w  w w.j  a v a  2  s .  c om*/

    ((MainActivity) getActivity()).closeSearch();

    MenuItem clearFiltersItem = menu.add(getResources().getString(R.string.btn_clear_filters));
    clearFiltersItem.setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_times)
            .colorRes(R.color.accentNoTransparency).actionBarSize());
    clearFiltersItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    clearFiltersItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            Toast.makeText(getActivity(), "Filters cleared", Toast.LENGTH_SHORT).show();

            try {
                DBManager.setAllCategoriesSelected(false);
            } catch (SQLException e) {
                e.printStackTrace();
            }

            ((FiltersCellAdapter) recyclerView.getAdapter()).refreshData();

            synchronized (RHCareerFairLayout.refreshCompaniesNotifier) {
                RHCareerFairLayout.refreshCompaniesNotifier.notifyChanged();
            }

            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    recyclerView.getAdapter().notifyDataSetChanged();
                }
            });

            return true;
        }
    });
}

From source file:finalproject.ece558.edu.pdx.ece.brailleblackjack.LearnBrailleActivity.java

/**
 * Create the action menu to provide buttons to navigate the Pager
 * @param menu Menu object//from  w  w w . j  a v a  2s .co m
 * @return Boolean true
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_main, menu);

    // Add/enable previous button depending on which page is active
    // is currently selected.
    MenuItem prev_item = menu.add(Menu.NONE, R.id.action_previous, Menu.NONE, R.string.action_previous);

    prev_item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);

    // Add either a "next" or "finished" button to the action bar, depending on which page
    // is currently active.
    MenuItem next_item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                    : R.string.action_next);
    next_item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    menu.findItem(R.id.action_next).setEnabled(!(mPager.getCurrentItem() == 3));

    menu.findItem(R.id.action_next).setEnabled(mPager.getCurrentItem() < 3);
    return true;
}

From source file:com.flashcard.iedu.flashcard.samples.cardFlip.MyCardFlipActivity.java

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

    // Add either a "photo" or "finish" button to the action bar, depending on which page
    // is currently selected.
    MenuItem item = menu.add(Menu.NONE, R.id.action_flip, Menu.NONE,
            mShowingBack ? R.string.action_photo : R.string.action_info);
    //        item.setIcon(mShowingBack
    //                ? R.drawable.ic_action_photo
    //                : R.drawable.ic_action_info);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    return true;//from  w  ww. j a va  2s  .  com
}

From source file:cz.msebera.unbound.dns.fragments.MainLogFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.add(Menu.NONE, MENU_CLEAR, Menu.NONE, R.string.menu_clear)
            .setIcon(android.R.drawable.ic_menu_close_clear_cancel)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    menu.add(Menu.NONE, MENU_EMPTY, Menu.NONE, R.string.mainlog_menu_truncate_log)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.epstudios.epcoding.ScreenSlideActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.activity_screen_slide, menu);

    menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);

    // Add either a "next" or "finish" button to the action bar, depending
    // on which page
    // is currently selected.
    MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                    : R.string.action_next);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;/*w w w. ja va 2 s  .  c om*/
}

From source file:org.strongswan.android.ui.SelectedApplicationsListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add(R.string.search);
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    SearchView sv = new SearchView(getActivity());
    sv.setOnQueryTextListener(this);
    item.setActionView(sv);//www  . j  a v a 2 s  .  co m

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.alfresco.mobile.android.application.fragments.actions.NodeIdActions.java

protected void getMenu(FragmentActivity activity, Menu menu) {
    SubMenu createMenu;//w  w w  .  ja  v a2s  . co  m

    // SYNC
    if (SyncContentManager.getInstance(getActivity()).hasActivateSync(getAccount())) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_sync_group, Menu.FIRST, R.string.sync);
        createMenu.setIcon(R.drawable.ic_sync_light);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        hideActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_SYNC);

        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_sync, Menu.FIRST + 1, R.string.sync);
        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_unsync, Menu.FIRST + 2, R.string.unsync);
    }

    // FAVORITES
    createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_favorite_group, Menu.FIRST + 2, R.string.favorite);
    createMenu.setIcon(R.drawable.ic_favorite_light);
    createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    hideActionIfNecessary(menu, createMenu.getItem().getItemId(),
            ConfigurableActionHelper.ACTION_NODE_FAVORITE);

    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_favorite, Menu.FIRST + 1, R.string.favorite);
    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_unfavorite, Menu.FIRST + 2, R.string.unfavorite);

    // LIKE
    AlfrescoSession alfSession = SessionUtils.getSession(activity);
    if (alfSession != null && alfSession.getRepositoryInfo() != null
            && alfSession.getRepositoryInfo().getCapabilities() != null
            && alfSession.getRepositoryInfo().getCapabilities().doesSupportLikingNodes()) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_like_group, Menu.FIRST + 3, R.string.like);
        createMenu.setIcon(R.drawable.ic_like);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        hideActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_LIKE);

        createMenu.add(Menu.NONE, R.id.menu_action_like_group_like, Menu.FIRST + 1, R.string.like);
        createMenu.add(Menu.NONE, R.id.menu_action_like_group_unlike, Menu.FIRST + 2, R.string.unlike);
    }
}