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.custom.music.MusicBrowserActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(0, PLAY_ALL, 0, R.string.play_all);
    menu.add(0, SHUFFLE_ALL, 0, R.string.shuffle_all);
    menu.add(0, EFFECTS_PANEL, 0, R.string.effects_list_title);
    /// M: Add search view
    mSearchItem = MusicUtils.addSearchView(this, menu, mQueryTextListener);
    /// M: Add folder to play
    menu.add(0, TrackBrowserActivity.ADD_FOLDER_TO_PLAY, 0, R.string.add_folder_to_play);
    /// M: Add folder as a playlist
    menu.add(0, PlaylistBrowserActivity.ADD_FOLDER_AS_PLAYLIST, 0, R.string.add_folder_as_playlist);
    /// M: add a file from filemanager to play all audio in the same folder.
    menu.add(0, TrackBrowserActivity.ADD_SONG_TO_PLAY, 0, R.string.add_song_to_play);
    return true;//from  w w w . ja  v  a2s  .  c  o  m
}

From source file:com.radicaldynamic.groupinform.activities.AccountFolderList.java

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

    boolean enabled = false;
    boolean visible = true;

    if (Collect.getInstance().getIoService().isSignedIn())
        enabled = true;//from   w  w w. jav  a2 s.  c  o m

    if (mCopyToFolder)
        visible = false;

    if (!Collect.getInstance().getInformOnlineState().getDeviceRole().equals(AccountDevice.ROLE_DATA_ENTRY)) {
        menu.add(0, MENU_ADD, 0, getString(R.string.tf_create_folder)).setIcon(R.drawable.ic_menu_add)
                .setEnabled(enabled).setVisible(visible);
    }

    menu.add(0, MENU_SYNC_LIST, 0, getString(R.string.tf_replication_list))
            .setIcon(R.drawable.ic_menu_sync_list).setEnabled(enabled).setVisible(visible);

    return true;
}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(0, MENU_PLAYBACK, 0, R.string.playback_view);
    menu.add(0, MENU_SEARCH, 0, R.string.search).setIcon(R.drawable.ic_menu_search).setVisible(false);
    menu.add(0, MENU_GO_HOME, 30, R.string.go_home);
    menu.add(0, MENU_SORT, 30, R.string.sort_by).setIcon(R.drawable.ic_menu_sort_alphabetically);
    return true;//from ww w.  ja v a  2  s  .  c o  m
}

From source file:com.bluros.updater.UpdatesSettings.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, MENU_REFRESH, 0, R.string.menu_refresh).setIcon(R.drawable.ic_menu_refresh)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    menu.add(0, MENU_DELETE_ALL, 0, R.string.menu_delete_all)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    menu.add(0, MENU_SYSTEM_INFO, 0, R.string.menu_system_info)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    return true;/*from  w  w w. jav a  2  s . co m*/
}

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

@Override
public void createMenu(Toolbar toolbar) {
    super.createMenu(toolbar);
    Menu menu = toolbar.getMenu();
    toolbar.inflateMenu(R.menu.fragment_show);

    if (inWatchlist) {
        menu.add(0, R.id.action_watchlist_remove, 300, R.string.action_watchlist_remove);
    } else {//from w  w  w.  j  ava  2s . com
        menu.add(0, R.id.action_watchlist_add, 300, R.string.action_watchlist_add);
    }

    if (isHidden) {
        menu.add(0, R.id.menu_show_show_upcoming, 400, R.string.action_show_show_upcoming);
    } else {
        menu.add(0, R.id.menu_show_hide_upcoming, 400, R.string.action_show_hide_upcoming);
    }
}

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    if (arole == null)
        arole = PleftDroidDbAdapter.R_INVITEE;
    if (arole.equals(PleftDroidDbAdapter.R_INVITOR)) {
        menu.add(0, RESENDINV_ID, 0, R.string.menu_resendinv).setIcon(android.R.drawable.ic_menu_send);
        menu.add(0, INVANOTHER_ID, 0, R.string.menu_invanother).setIcon(R.drawable.ic_menu_invite);
    }//from  w  w  w.j  av  a 2 s  . co  m
    if (arole.equals(PleftDroidDbAdapter.R_INVITOR) || canproposedates) { //if Invitor or can propose dates is set
        menu.add(0, PROPOSEDATE_ID, 0, R.string.menu_proposedate).setIcon(android.R.drawable.ic_menu_today);
    }
    menu.add(0, DONE_ID, 0, R.string.menu_done).setIcon(android.R.drawable.ic_menu_save);
    return true;
}

From source file:com.air.mobilebrowser.BrowserActivity.java

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

    //- Remove exit functionality, exit will be via javascript only.
    menu.add(0, 0, 0, "Exit").setIcon(android.R.drawable.ic_menu_close_clear_cancel)
            .setAlphabeticShortcut(SearchManager.MENU_KEY);

    /* Disabled Settings - Uncomment if needed (otherwise this will be removed later, along with the settings code) */
    /*// w w  w.jav  a  2s  . com
    menu.add(0, 1, 0, R.string.menu_settings)
    .setIcon(android.R.drawable.ic_menu_preferences)
    .setIntent(new Intent(android.provider.Settings.ACTION_SETTINGS));
     */

    return true;
}

From source file:com.github.jobs.ui.fragment.JobDetailsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    Context themedContext = getActivity().getActionBar().getThemedContext();
    ShareActionProvider shareActionProvider = new ShareActionProvider(themedContext);
    shareActionProvider/* w w w .  j a  va 2 s .co  m*/
            .setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
                @Override
                public boolean onShareTargetSelected(ShareActionProvider shareActionProvider, Intent intent) {
                    getTracker(getActivity()).trackEvent(CATEGORY_JOBS, ACTION_SHARE,
                            intent.getComponent().getPackageName());
                    return false;
                }
            });
    menu.add(0, SHARE, 0, R.string.share).setActionProvider(shareActionProvider)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(SHARE);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    actionProvider.setShareIntent(ShareHelper.getShareIntent(mJob));
}

From source file:org.alfresco.mobile.android.application.fragments.person.PersonProfileFragment.java

private void getMenu(Menu menu, int mode) {
    MenuItem mi = null;/*from   ww w.j  a v a  2 s. co m*/
    switch (mode) {
    case MODE_CALL:
        if (person.getTelephoneNumber() != null && !person.getTelephoneNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, MenuActionItem.MENU_TEL, Menu.FIRST + MenuActionItem.MENU_TEL,
                    person.getTelephoneNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getMobileNumber() != null && !person.getMobileNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, MenuActionItem.MENU_MOBILE, Menu.FIRST + MenuActionItem.MENU_MOBILE,
                    person.getMobileNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getCompany() != null && person.getCompany().getTelephoneNumber() != null
                && !person.getCompany().getTelephoneNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, MenuActionItem.MENU_COMPANY_TEL,
                    Menu.FIRST + MenuActionItem.MENU_COMPANY_TEL, person.getCompany().getTelephoneNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
        break;
    case MODE_SKYPE:
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_CHAT, Menu.FIRST + MenuActionItem.MENU_CHAT,
                R.string.start_chat);
        mi.setIcon(R.drawable.ic_im);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

        mi = menu.add(Menu.NONE, MenuActionItem.MENU_CALL, Menu.FIRST + MenuActionItem.MENU_CALL,
                R.string.start_call);
        mi.setIcon(R.drawable.ic_call);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

        mi = menu.add(Menu.NONE, MenuActionItem.MENU_VIDEOCALL, Menu.FIRST + MenuActionItem.MENU_VIDEOCALL,
                R.string.start_video_call);
        mi.setIcon(R.drawable.ic_videocall);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        break;
    case MODE_EMAIL:
        if (person.getEmail() != null && !person.getEmail().isEmpty()) {
            mi = menu.add(Menu.NONE, MenuActionItem.MENU_EMAIL, Menu.FIRST + MenuActionItem.MENU_EMAIL,
                    person.getEmail());
            mi.setIcon(R.drawable.ic_send_mail);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getCompany() != null && person.getCompany().getEmail() != null
                && !person.getCompany().getEmail().isEmpty()) {
            mi = menu.add(Menu.NONE, MenuActionItem.MENU_COMPANY_EMAIL,
                    Menu.FIRST + MenuActionItem.MENU_COMPANY_EMAIL, person.getCompany().getEmail());
            mi.setIcon(R.drawable.ic_send_mail);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
        break;

    default:
        break;
    }

}

From source file:jp.ksksue.app.terminal.AndroidUSBSerialMonitorLite.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(Menu.NONE, MENU_ID_OPENDEVICE, Menu.NONE, "Open Device");
    menu.add(Menu.NONE, MENU_ID_WORDLIST, Menu.NONE, "Word List ...");
    menu.add(Menu.NONE, MENU_ID_SETTING, Menu.NONE, "Setting ...");
    menu.add(Menu.NONE, MENU_ID_CLEARTEXT, Menu.NONE, "Clear Text");
    menu.add(Menu.NONE, MENU_ID_SENDTOEMAIL, Menu.NONE, "Email to ...");
    menu.add(Menu.NONE, MENU_ID_CLOSEDEVICE, Menu.NONE, "Close Device");
    /*        if(mSerial!=null) {
    if(mSerial.isConnected()) {/*from ww w.  j a v a 2  s.co  m*/
        menu.getItem(MENU_ID_OPENDEVICE).setEnabled(false);
    } else {
        menu.getItem(MENU_ID_CLOSEDEVICE).setEnabled(false);
    }
            }
    */ return super.onCreateOptionsMenu(menu);
}