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.sim2dial.dialer.HistorySimpleFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, v.getId(), 0, getString(R.string.delete));
    // getActivity().getMenuInflater().inflate(R.menu.menu_layout, menu);
}

From source file:org.onebusaway.android.ui.MyRemindersFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    final TextView text = (TextView) info.targetView.findViewById(R.id.name);
    menu.setHeaderTitle(text.getText());
    menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.trip_list_context_edit);
    menu.add(0, CONTEXT_MENU_DELETE, 0, R.string.trip_list_context_delete);
    menu.add(0, CONTEXT_MENU_SHOWSTOP, 0, R.string.trip_list_context_showstop);
    menu.add(0, CONTEXT_MENU_SHOWROUTE, 0, R.string.trip_list_context_showroute);
}

From source file:com.BreakingBytes.SifterReader.SifterReader.java

/** List context menu options. */
@Override//from   w w w . j  a v a  2  s . c  o m
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, MILESTONES_ID, 0, R.string.milestones);
    menu.add(0, CATEGORIES_ID, 0, R.string.categories);
    menu.add(0, PEOPLE_ID, 0, R.string.people);
    menu.add(0, ISSUES_ID, 0, R.string.issues);
    menu.setHeaderTitle(R.string.menu_header);
}

From source file:ivl.android.moneybalance.CalculationListActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == R.id.calculation_list) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        cursor.moveToPosition(info.position);
        Calculation calculation = dataSource.fromCursor(cursor);
        menu.setHeaderTitle(calculation.getTitle());
        menu.add(0, ITEM_DELETE, 0, R.string.menu_delete);
        menu.add(0, ITEM_SUMMARY, 0, R.string.calculation_summary);
    }/*  w  w  w . j a v  a  2  s  . co m*/
}

From source file:monakhv.android.samlib.AuthorTagsActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    cursor = null;/*w w w . ja v  a  2  s .  co  m*/
    if (v.getId() == R.id.listTags) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;

        cursor = (Cursor) adapter.getItem(info.position);
        menu.add(1, delete_menu_id, 2, getText(R.string.menu_delete));
        menu.add(1, edit_menu_id, 1, getText(R.string.menu_edit));
    }
}

From source file:org.kochka.android.weightlogger.WeightLoggerActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == R.id.mListView) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        menu.setHeaderTitle(((Measurement) mList.getItemAtPosition(info.position)).getFormatedRecordedAt());
        menu.add(Menu.NONE, 0, 0, R.string.edit);
        menu.add(Menu.NONE, 1, 1, R.string.delete);
    }/*from   ww w  .j a va  2s . c  o m*/
}

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    final TextView text = (TextView) info.targetView.findViewById(R.id.short_name);
    menu.setHeaderTitle(getString(R.string.route_name, text.getText()));
    if (isShortcutMode()) {
        menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.my_context_create_shortcut);
    } else {/*www .  j  av  a2 s .  c o m*/
        menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.my_context_get_route_info);
    }
    menu.add(0, CONTEXT_MENU_SHOW_ON_MAP, 0, R.string.my_context_showonmap);
    final String url = getUrl(getListView(), info.position);
    if (url != null) {
        menu.add(0, CONTEXT_MENU_SHOW_URL, 0, R.string.my_context_show_schedule);
    }
}

From source file:joshuatee.wx.MiscFragment.java

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

    switch (v.getId()) {
    case R.id.iv_10: // STATE
        String state_cur = preferences.getString("STATE_CODE", "");
        menu.add(0, v.getId(), 0, "Edit State (" + state_cur + ")");
        break;/*from w  w w.java2s .c o m*/
    case R.id.iv_9: // conus mosaic
        menu.setHeaderTitle("Beta area");
        menu.add(0, v.getId(), 0, "Iowa Mesonet hires conus radar");
        menu.add(0, v.getId(), 0, "SPC Compmap");

        break;
    case R.id.iv_8: // conus mosaic
        menu.setHeaderTitle("Set default sector");
        menu.add(0, v.getId(), 0, "alaska");
        menu.add(0, v.getId(), 0, "hawaii");
        menu.add(0, v.getId(), 0, "pacsouthwest");
        menu.add(0, v.getId(), 0, "pacnorthwest");
        menu.add(0, v.getId(), 0, "southrockies");
        menu.add(0, v.getId(), 0, "northrockies");
        menu.add(0, v.getId(), 0, "uppermissvly");
        menu.add(0, v.getId(), 0, "southplains");
        menu.add(0, v.getId(), 0, "centgrtlakes");
        menu.add(0, v.getId(), 0, "southmissvly");
        menu.add(0, v.getId(), 0, "southeast");
        menu.add(0, v.getId(), 0, "northeast");
        menu.add(0, v.getId(), 0, "conus");
        break;
    case R.id.iv_7: // conus mosaic
        menu.setHeaderTitle("Set default sector");
        menu.add(0, v.getId(), 0, "alaska");
        menu.add(0, v.getId(), 0, "hawaii");
        menu.add(0, v.getId(), 0, "pacsouthwest");
        menu.add(0, v.getId(), 0, "pacnorthwest");
        menu.add(0, v.getId(), 0, "southrockies");
        menu.add(0, v.getId(), 0, "northrockies");
        menu.add(0, v.getId(), 0, "uppermissvly");
        menu.add(0, v.getId(), 0, "southplains");
        menu.add(0, v.getId(), 0, "centgrtlakes");
        menu.add(0, v.getId(), 0, "southmissvly");
        menu.add(0, v.getId(), 0, "southeast");
        menu.add(0, v.getId(), 0, "northeast");
        menu.add(0, v.getId(), 0, "conus");
        break;
    case R.id.iv_1:
        menu.add(0, v.getId(), 0, "COD Model Web");
        break;

    }

}

From source file:com.orangelabs.rcs.ri.sharing.image.ImageSharingList.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (!isServiceConnected(RcsServiceName.IMAGE_SHARING)) {
        showMessage(R.string.label_service_not_available);
        return;/*from ww  w. j av  a2  s  .co m*/
    }
    menu.add(0, MENU_ITEM_DELETE, MENU_ITEM_DELETE, R.string.menu_sharing_delete);
}

From source file:com.dhara.googlecalendartrial.MainActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    String title = mEventList.get(info.position).getDescription();
    menu.setHeaderTitle(title);/*from   w w w .j  av a  2 s . c o m*/
    menu.add(Menu.NONE, 1, Menu.NONE, getString(R.string.delete_event));
}