Example usage for android.view ContextMenu add

List of usage examples for android.view ContextMenu add

Introduction

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

Prototype

public MenuItem add(int groupId, int itemId, int order, CharSequence title);

Source Link

Document

Add a new item to the menu.

Usage

From source file:org.chromium.chrome.browser.ntp.snippets.SnippetArticleViewHolder.java

/**
 * Convenience method to reduce multi-line function call to single line.
 *///from   www. ja va  2s  .com
private static void addContextMenuItem(ContextMenu menu, int id, int resourceId,
        OnMenuItemClickListener listener) {
    menu.add(Menu.NONE, id, Menu.NONE, resourceId).setOnMenuItemClickListener(listener);
}

From source file:org.mixare.MixListView.java

public static void createContextMenu(ImageView icon) {
    icon.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            int index = 0;
            switch (ListItemAdapter.itemPosition) {
            case 0:
                menu.setHeaderTitle("Wiki Menu");
                menu.add(index, index, index, "We are working on it...");
                break;
            case 1:
                menu.setHeaderTitle("Twitter Menu");
                menu.add(index, index, index, "We are working on it...");
                break;
            case 2:
                menu.setHeaderTitle("Buzz Menu");
                menu.add(index, index, index, "We are working on it...");
                break;
            case 3:
                menu.setHeaderTitle("OpenStreetMap Menu");
                menu.add(index, index, index, "We are working on it...");
                break;
            case 4:
                AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
                alert.setTitle("insert your own URL:");

                final EditText input = new EditText(ctx);
                input.setText(customizedURL);
                alert.setView(input);//from   w  w  w .  j a va 2s  .com

                alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        Editable value = input.getText();
                        customizedURL = "" + value;
                    }
                });
                alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                    }
                });
                alert.show();
                break;
            }
        }
    });

}

From source file:com.tnc.android.graphite.fragments.SavedGraphsFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, v.getId(), 0, R.string.saved_dialog_delete);
}

From source file:can.yrt.onebusaway.MyRecentRoutesFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, CONTEXT_MENU_DELETE, 0, R.string.my_context_remove_recent);
}

From source file:can.yrt.onebusaway.MyStarredStopsFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, MyListConstants.CONTEXT_MENU_DELETE, 0, R.string.my_context_remove_star);
}

From source file:net.meiolania.apps.habrahabr.fragments.posts.PostsCommentsFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);

    menu.add(0, MENU_OPEN_COMMENT_IN_BROWSER, 0, R.string.open_comment_in_browser);
    menu.add(0, MENU_OPEN_AUTHOR_PROFILE, 0, R.string.open_author_profile);
}

From source file:at.alladin.rmbt.android.sync.RMBTSyncRequestCodeFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo contextMenuInfo) {
    if (view instanceof TextView && view == codeText)
        menu.add(Menu.NONE, view.getId(), Menu.NONE, R.string.sync_request_code_context_copy);
    else/*w ww . ja v a 2  s.  c o m*/
        super.onCreateContextMenu(menu, view, contextMenuInfo);
}

From source file:id.nci.stm_9.KeyListSecretFragment.java

/**
 * Context Menu on Long Click// w  w w.  j a  v a  2  s.c o  m
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, 0x21070003, 0, R.string.menu_edit_key);
}

From source file:org.sufficientlysecure.keychain.ui.KeyListSecretFragment.java

/**
 * Context Menu on Long Click/*from  www.j  a v  a 2  s.co  m*/
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, Id.menu.edit, 0, R.string.menu_editKey);
}