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:com.g_node.gca.abstracts.AbstractNotesFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; // ??
    int currentNoteId = (int) info.id;
    menu.add(0, 2, 0, "Edit");
    menu.add(0, 3, 1, "Delete");
}

From source file:com.may.ple.parking.gateway.activity.GateOutActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle("??");
    menu.add(0, 1, 0, "Ticket ");
    menu.add(0, 2, 1, "Ticket ??");
}

From source file:de.grundid.plusrad.MainActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, CONTEXT_RETRY, 0, "Retry Upload");
    menu.add(0, CONTEXT_DELETE, 0, "Delete");
}

From source file:com.simplaapliko.wakeup.sample.ui.MainActivityFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    menu.add(0, CONTEXT_MENU_DELETE, 0, "Delete");
}

From source file:org.akvo.flow.ui.fragment.ResponseListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);
    menu.add(0, VIEW_HISTORY, 0, R.string.transmissionhist);

    // Allow deletion only for 'saved' responses
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    View itemView = info.targetView;
    if (!(Boolean) itemView.getTag(FINISHED_KEY)) {
        menu.add(0, DELETE_ONE, 2, R.string.deleteresponse);
    }//  w w w.ja  v  a2 s. co m
}

From source file:edu.illinois.whereru.FriendListFragment.java

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

    menu.add(Menu.NONE, FRIEND_SETTING_MENU_ID, Menu.NONE, "Setting");
    menu.add(Menu.NONE, FRIEND_REMOVE_MENU_ID, Menu.NONE, "Remove");
}

From source file:org.akvo.flow.activity.ListUserActivity.java

/**
 * presents an edit and "delete" option when the user long-clicks a list
 * item/*from ww  w  . j  av a2 s  .c  o  m*/
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    // the parent method adds the "edit" button
    menu.add(0, EDIT_ID, EDIT_ID, R.string.editmenu);
    menu.add(0, DELETE_ID, DELETE_ID, R.string.deleteusermenu);
}

From source file:org.sensapp.android.sensappdroid.fragments.CompositeListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, MENU_DELETE_ID, 0, "Delete composite");
    menu.add(0, MENU_MANAGESENSORS_ID, 0, "Manage sensors");
    menu.add(0, MENU_UPLOAD_ID, 0, "Upload composite");
}

From source file:com.pixellostudio.qqdroid.BaseQuote.java

/** Called when the activity is first created. */
@Override/*from  w  w w.  j av  a  2  s  . c om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setActionBarContentView(R.layout.show);

    getActionBar().setTitle(title);

    getActionBar().addItem(getActionBar().newActionBarItem(NormalActionBarItem.class)
            .setDrawable(R.drawable.seemore).setContentDescription("List"), R.id.actionbar_seemore);

    view = (ListView) findViewById(R.id.ListView);

    view.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            menu.add(0, 1, 0, R.string.sharequote);
        }
    });

    adapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1);
    adapter2 = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(BaseQuote.this);

            TextView txt = new TextView(this.getContext());
            txt.setTextSize(Float.parseFloat(pref.getString("policesize", "20")));
            txt.setText(Html.fromHtml(this.getItem(position)));

            if (pref.getString("design", "blackonwhite").equals("blackonwhite")) {
                txt.setTextColor(Color.BLACK);
                txt.setBackgroundColor(Color.WHITE);
                txt.setBackgroundDrawable(
                        this.getContext().getResources().getDrawable(R.drawable.quote_gradient_white));
            } else if (pref.getString("design", "blackonwhite").equals("whiteonblack")) {
                txt.setTextColor(Color.WHITE);
                txt.setBackgroundColor(Color.BLACK);
                txt.setBackgroundDrawable(
                        this.getContext().getResources().getDrawable(R.drawable.quote_gradient_black));
            }

            return txt;
        }

    };

    String[] liste = (String[]) getLastNonConfigurationInstance();

    if (liste != null && liste.length != 0) {
        for (int i = 0; i < liste.length; i++) {
            adapter.add(liste[i]);
            adapter2.add(liste[i]);
        }

        this.setTitle(name);
    } else {
        new LoadQuotes().execute();
    }

    view.setAdapter(adapter2);
}

From source file:com.zoterodroid.activity.BrowseCitations.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.browse_bookmarks);

    mAccountManager = AccountManager.get(this);
    mAccount = mAccountManager.getAccountsByType(Constants.ACCOUNT_TYPE)[0];
    mContext = this;

    Log.d("browse bookmarks", getIntent().getDataString());
    Uri data = getIntent().getData();/* w  ww . ja  v a2 s  .c o  m*/
    String scheme = data.getScheme();
    String path = data.getPath();
    Log.d("path", path);
    String username = data.getQueryParameter("username");
    String tagname = data.getQueryParameter("tagname");
    String recent = data.getQueryParameter("recent");

    myself = mAccount.name.equals(username);

    ArrayList<Citation> citationList = new ArrayList<Citation>();

    if (scheme.equals("content") && path.equals("/citations") && myself) {

        try {

            String[] projection = new String[] { Citation._ID, Citation.Title, Citation.Key,
                    Citation.Creator_Summary, Citation.Item_Type };
            String selection = null;
            String sortorder = null;

            selection = Citation.Account + " = '" + username + "'";

            Uri citations = Citation.CONTENT_URI;

            Cursor c = managedQuery(citations, projection, selection, null, sortorder);

            if (c.moveToFirst()) {
                int idColumn = c.getColumnIndex(Citation._ID);
                int titleColumn = c.getColumnIndex(Citation.Title);
                int keyColumn = c.getColumnIndex(Citation.Key);
                int creatorSummaryColumn = c.getColumnIndex(Citation.Creator_Summary);
                int itemTypeColumn = c.getColumnIndex(Citation.Item_Type);

                do {

                    Citation b = new Citation(c.getInt(idColumn), c.getString(titleColumn),
                            c.getString(keyColumn), c.getString(creatorSummaryColumn),
                            c.getString(itemTypeColumn));

                    citationList.add(b);

                } while (c.moveToNext());

            }

            setListAdapter(new CitationListAdapter(this, R.layout.bookmark_view, citationList));
        } catch (Exception e) {
        }

    }

    lv = getListView();
    lv.setTextFilterEnabled(true);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

        }
    });

    /* Add Context-Menu listener to the ListView. */
    lv.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            menu.setHeaderTitle("Actions");
            if (myself) {
                menu.add(Menu.NONE, 0, Menu.NONE, "Delete");
            } else {
                menu.add(Menu.NONE, 1, Menu.NONE, "Add");
            }

        }
    });
}