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(@StringRes int titleRes);

Source Link

Document

Add a new item to the menu.

Usage

From source file:net.sakuramilk.kbcupdater.MainFragmentActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add("Update list");
    MenuItem actionItem = menu.add("Update list");
    actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    actionItem.setIcon(android.R.drawable.ic_menu_manage);

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

From source file:fi.aalto.legroup.achso.browsing.DetailActivity.java

/**
 * Using the Google Maps API via Google Play Services requires displaying its licence
 * information. We'll show the information in an AlertDialog triggered by a MenuItem.
 *///from  www .java2s  .  co m
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(R.string.about_maps).setOnMenuItemClickListener(this);
    return true;
}

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // ?????//from  w  ww. jav  a 2 s . 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:com.example.sqlbrite.todo.ui.ListsFragment.java

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

    MenuItem item = menu.add(R.string.new_list)
            .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                @Override//  www .  j a  v a2 s  .  co m
                public boolean onMenuItemClick(MenuItem item) {
                    listener.onNewListClicked();
                    return true;
                }
            });
    MenuItemCompat.setShowAsAction(item, SHOW_AS_ACTION_IF_ROOM | SHOW_AS_ACTION_WITH_TEXT);
}

From source file:geralt_encore.delightfulsqlbrite.todo.ui.ListsFragment.java

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

    MenuItem item = menu.add(R.string.new_list).setOnMenuItemClickListener(clickedItem -> {
        listener.onNewListClicked();// www.j ava 2s.  co  m
        return true;
    });
    MenuItemCompat.setShowAsAction(item, SHOW_AS_ACTION_IF_ROOM | SHOW_AS_ACTION_WITH_TEXT);
}

From source file:com.example.ward.view.CursorFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    SearchView sv = new SearchView(getActivity());
    sv.setOnQueryTextListener(this);
    item.setActionView(sv);//from   w w  w  . ja  v  a 2 s  .  c  om
}

From source file:org.urbanstew.SoundCloudBase.SoundCloudMainActivity.java

/**
 * Sets up menu options.  Currently all have to do with defect / bug reports and discussion group.
 *///  ww  w  . j  a v a  2  s . co m
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    mView = menu.add("View reported defects and feature requests").setIcon(android.R.drawable.ic_dialog_info);
    mReport = menu.add("Report defect or feature request").setIcon(android.R.drawable.ic_dialog_alert);
    mJoinGroup = menu.add("Join discussion group").setIcon(android.R.drawable.ic_dialog_email);
    //mSettingsMenuItem = menu.add("Preferences").setIcon(android.R.drawable.ic_menu_preferences);
    mManualMenuItem = menu.add("Read the manual").setIcon(android.R.drawable.ic_menu_manage);
    return true;
}

From source file:com.example.android.supportv4.app.SharingSupport.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    ShareCompat.IntentBuilder b = ShareCompat.IntentBuilder.from(this);
    b.setType("text/plain").setText("Share from menu");
    MenuItem item = menu.add("Share");
    ShareCompat.configureMenuItem(item, b);
    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    return true;/*  w  w w  . j av  a 2  s .  c o  m*/
}

From source file:geralt_encore.delightfulsqlbrite.todo.ui.ItemsFragment.java

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

    MenuItem item = menu.add(R.string.new_item).setOnMenuItemClickListener(clickedItem -> {
        listener.onNewItemClicked(getListId());
        return true;
    });/*from  ww w  .j  a va2s  .  co m*/
    MenuItemCompat.setShowAsAction(item, SHOW_AS_ACTION_IF_ROOM | SHOW_AS_ACTION_WITH_TEXT);
}

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);/*  ww  w  .  jav a  2s .c o m*/
}