Example usage for android.view Menu add

List of usage examples for android.view Menu add

Introduction

In this page you can find the example usage for android.view Menu add.

Prototype

public MenuItem add(int groupId, int itemId, int order, @StringRes int titleRes);

Source Link

Document

Variation on #add(int,int,int,CharSequence) that takes a string resource identifier instead of the string itself.

Usage

From source file:com.mifos.mifosxdroid.online.CollectionSheetFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {

    menu.clear();//  w  w w.  j ava  2  s .co 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(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(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:net.illusor.swipeplayer.activities.SwipeActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, MENU_CODE_ABOUT, 0, R.string.str_menu_about);
    menu.add(0, MENU_CODE_QUIT, 0, R.string.str_menu_exit);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.alphabetbloc.accessmrs.ui.user.BaseUserActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(0, MENU_REFRESH, MENU_REFRESH, getString(R.string.download_patients))
            .setIcon(R.drawable.ic_menu_refresh);
    menu.add(0, MENU_USER_PREFERENCES, MENU_USER_PREFERENCES, getString(R.string.pref_settings))
            .setIcon(android.R.drawable.ic_menu_preferences);
    menu.add(0, MENU_ADMIN_PREFERENCES, MENU_ADMIN_PREFERENCES, getString(R.string.pref_admin_settings))
            .setIcon(android.R.drawable.ic_lock_lock);
    return true;//from  w  ww.  jav a2 s  .c  o  m
}

From source file:com.mifos.mifosxdroid.online.collectionsheet.CollectionSheetFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {

    menu.clear();/*from  ww  w.  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.pepperonas.truthordare.fragments.FragmentMultiplayer.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    menu.add(0, 0, 0, "Start").setIcon(R.drawable.ic_marked_circle_white_24dp)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    menu.getItem(0).setOnMenuItemClickListener(this);
}

From source file:net.sourceforge.servestream.activity.OrganizeUrlsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    TypedArray drawables = obtainStyledAttributes(new int[] { R.attr.navigation_accept });
    MenuItem item = menu.add(Menu.NONE, MENU_ID_ACCEPT, Menu.NONE, R.string.confirm_label);
    item.setIcon(drawables.getDrawable(0));
    MenuItemCompat.setShowAsAction(item,
            MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
    return true;/*from  w  w w  .j a  va 2 s  .c  om*/
}

From source file:de.stadtrallye.rallyesoft.fragments.TasksOverviewFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem refreshMenuItem = menu.add(Menu.NONE, R.id.refresh_menu, 30, R.string.refresh);
    refreshMenuItem.setIcon(R.drawable.ic_refresh_light);
    refreshMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    MenuItem resize = menu.add(Menu.NONE, R.id.resize_menu, 40, R.string.resize);
    resize.setIcon(R.drawable.ic_center_light);
    resize.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}

From source file:com.gh4a.activities.IssueListMineActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    int resIdState = Constants.Issue.STATE_OPEN.equals(mState) ? R.string.issues_menu_show_closed
            : R.string.issues_menu_show_open;
    MenuItem item = menu.add(Menu.NONE, Menu.FIRST + 1, Menu.NONE, resIdState);
    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    return super.onCreateOptionsMenu(menu);
}

From source file:net.openfiretechnologies.veloxcontrol.github.CommitsFragment.java

public void onPrepareOptionsMenu(Menu menu) {
    // remove old menu items
    menu.clear();/*  ww  w  .j  a  va  2  s  .c o m*/
    // add projects as option
    // cant change branch if we are not viewing a project folder's commits
    if (GithubViewer.ARE_IN_PROJECT_PATH)
        menu.add(0, GithubViewer.MENU_ID_COMMITLOG, 0, getString(R.string.changelog_menu_commitlog_title));
    else
        menu.add(0, GithubViewer.MENU_ID_PACKAGES, 0, getString(R.string.changelog_menu_projects_title));
}

From source file:com.darsihmad.slideScreen.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);

    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  ww.j  ava  2  s  .co  m
}