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.android.settings.aicp.AicpSettings.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.add(0, MENU_HELP, 0, "Help Us, Help You!!").setIcon(R.drawable.ic_action_help)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}

From source file:com.keithandthegirl.ui.activity.EpisodesActivity.java

@TargetApi(11)
@Override/*  w  w w  . j a  va 2  s  . com*/
public boolean onCreateOptionsMenu(Menu menu) {
    Log.d(TAG, "onCreateOptionsMenu : enter");

    MenuItem settings = menu.add(Menu.NONE, SETTINGS_ID, Menu.NONE,
            getResources().getString(R.string.pref_settings_title));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        settings.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    MenuItem about = menu.add(Menu.NONE, ABOUT_ID, Menu.NONE, getResources().getString(R.string.about_header));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        about.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    Log.d(TAG, "onCreateOptionsMenu : exit");
    return super.onCreateOptionsMenu(menu);
}

From source file:com.grarak.kerneladiutor.activities.EditorActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_save);
    DrawableCompat.setTint(drawable, Color.WHITE);
    menu.add(0, Menu.FIRST, Menu.FIRST, getString(R.string.save)).setIcon(drawable)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    return super.onCreateOptionsMenu(menu);
}

From source file:edu.princeton.jrpalmer.asmlibrary.ListMyDataCursorLoader.java

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

    menu.add(0, LOCATE_NOW, Menu.NONE, R.string.menu_locate_now);

    return true;/*from   w  ww. j  av  a 2 s  .  co m*/

}

From source file:net.lacolaco.smileessence.activity.EditExtractionActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem add = menu.add(Menu.NONE, R.id.menu_edit_list_add, Menu.NONE, "");
    add.setIcon(android.R.drawable.ic_menu_add);
    add.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    return true;/*from ww  w . j  a  v a  2  s. co m*/
}

From source file:org.alfresco.mobile.android.application.fragments.site.browser.SiteAdapter.java

public void getMenu(Menu menu, Site site) {
    if (site.isMember()) {
        menu.add(Menu.NONE, R.id.menu_site_leave, Menu.FIRST + 2, R.string.action_leave_site);
    } else if (!SiteVisibility.PRIVATE.equals(site.getVisibility()) && !site.isPendingMember()) {
        menu.add(Menu.NONE, R.id.menu_site_join, Menu.FIRST + 1,
                (SiteVisibility.MODERATED.equals(site.getVisibility())) ? R.string.action_join_request_site
                        : R.string.action_join_site);
    }//w w w .j a  va2s .  c  o m

    if (site.isFavorite()) {
        menu.add(Menu.NONE, R.id.menu_site_unfavorite, Menu.FIRST + 5, R.string.action_unfavorite_site);
    } else {
        menu.add(Menu.NONE, R.id.menu_site_favorite, Menu.FIRST + 4, R.string.action_favorite_site);
    }

    menu.add(Menu.NONE, R.id.menu_site_members, Menu.FIRST, R.string.members);
}

From source file:eu.thecoder4.gpl.pleftdroid.EditEventActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, RMINVITEE_ID, 0, R.string.menu_rminvitee).setIcon(android.R.drawable.ic_input_delete);
    menu.add(0, RMDATE_ID, 0, R.string.menu_rmdate).setIcon(android.R.drawable.ic_menu_day);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.yeldi.yeldibazaar.SearchResults.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    super.onCreateOptionsMenu(menu);
    MenuItem search = menu.add(Menu.NONE, SEARCH, 1, R.string.menu_search)
            .setIcon(android.R.drawable.ic_menu_search);
    MenuItemCompat.setShowAsAction(search, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    return true;/*from ww w.j a v a2  s .  c  om*/
}

From source file:com.mongolduu.android.ng.ChartActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean retValue = super.onCreateOptionsMenu(menu);
    menu.add(0, R.id.context_menu_home, 0, R.string.context_menu_home);
    menu.add(0, R.id.context_menu_search, 0, R.string.context_menu_search);
    menu.add(0, R.id.context_menu_refresh, 0, R.string.context_menu_refresh);
    return retValue;
}

From source file:com.tastycactus.timesheet.TimeEntriesActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean result = super.onCreateOptionsMenu(menu);
    menu.add(Menu.NONE, ADD_TIME_ENTRY_MENU_ITEM, Menu.NONE, "Add Time Entry")
            .setIcon(android.R.drawable.ic_menu_add);
    menu.add(Menu.NONE, EXPORT_MENU_ITEM, Menu.NONE, "Export to CSV").setIcon(android.R.drawable.ic_menu_save);
    menu.add(Menu.NONE, EMAIL_MENU_ITEM, Menu.NONE, "Send Email").setIcon(android.R.drawable.ic_menu_send);
    return result;
}