@Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   menu.add(0, CONTEXT_EDIT, 0, R.string.edit);
   menu.add(0, CONTEXT_DELETE, 0, R.string.delete);
   menu.add(0, CONTEXT_BATCH_ADD, 0, R.string.batchadd);
 }
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   menu.setHeaderTitle("Select The Action");
   menu.add(0, v.getId(), 0, "Call");
   menu.add(0, v.getId(), 0, "Send SMS");
 }
예제 #3
0
 @Override
 public void onCreateContextMenu(
     final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   menu.add(0, MENU_DELETE_ONE, 0, R.string.delete);
   menu.add(0, MENU_EDIT, 0, R.string.edit);
 }
예제 #4
0
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
   Log.e("GET ACTION", v.toString());
   getTxtView = (TextView) v;
   menu.add(0, EDIT, 0, "EDIT");
   menu.add(0, DELETE, 0, "DELETE");
 }
예제 #5
0
  /** {@inheritDoc} */
  @Override
  public void onCreateContextMenu(
      final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    // Get the position of the selected item
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    // Creat a new model
    mArtist = mAdapter.getItem(info.position);
    // Create a list of the artist's songs
    mArtistList = MusicUtils.getSongListForArtist(getActivity(), mArtist.mArtistId);

    // Play the artist
    menu.add(
        GROUP_ID,
        FragmentMenuItems.PLAY_SELECTION,
        Menu.NONE,
        getString(R.string.context_menu_play_selection));

    // Add the artist to the queue
    menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, getString(R.string.add_to_queue));

    // Add the artist to a playlist
    final SubMenu subMenu =
        menu.addSubMenu(
            GROUP_ID, FragmentMenuItems.ADD_TO_PLAYLIST, Menu.NONE, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(getActivity(), GROUP_ID, subMenu, false);

    // Delete the artist
    menu.add(
        GROUP_ID, FragmentMenuItems.DELETE, Menu.NONE, getString(R.string.context_menu_delete));
  }
예제 #6
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {

    super.onCreateContextMenu(menu, v, menuInfo);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    int ItemPosition = info.position;

    if (item_list.get(ItemPosition).get("StoreType").equals("2")) menu.add(0, 3, 0, "顯示我的商品");

    if (item_list.get(ItemPosition).get("ChangeNumberCheck").equals("0"))
      menu.add(0, 0, 0, "顯示換號清單");
    else if (item_list.get(ItemPosition).get("ChangeNumberCheck").equals("1")) {
      menu.add(0, 1, 0, "取消換號配對");

    } else if (item_list.get(ItemPosition).get("ChangeNumberCheck").equals("2")) {
      menu.add(0, 1, 1, "取消換號配對");
      menu.add(0, 2, 0, "確認換號配對");
    } else if (item_list.get(ItemPosition).get("ChangeNumberCheck").equals("3")) {
    } else {
      // menu.add(0, 0, 0, "進入換號系統");
    }

    menu.add(0, 4, 0, "刪除");
  }
예제 #7
0
  @Override
  public ContextMenuSubject getSubject(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    ContextMenuSubject subject = null;

    if (!(menuInfo instanceof AdapterView.AdapterContextMenuInfo)) {
      Log.e(LOGTAG, "menuInfo is not AdapterContextMenuInfo");
      return subject;
    }

    ListView list = (ListView) view;
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    subject = ((AwesomeBarItem) list.getItemAtPosition(info.position)).getSubject();

    if (subject == null) return subject;

    MenuInflater inflater = new MenuInflater(mContext);
    inflater.inflate(R.menu.awesomebar_contextmenu, menu);
    menu.findItem(R.id.remove_bookmark).setVisible(false);
    menu.findItem(R.id.edit_bookmark).setVisible(false);
    menu.findItem(R.id.open_in_reader).setVisible(subject.display == Combined.DISPLAY_READER);

    // Hide "Remove" item if there isn't a valid history ID
    if (subject.id < 0) menu.findItem(R.id.remove_history).setVisible(false);

    menu.setHeaderTitle(subject.title);
    return subject;
  }
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   menu.setHeaderTitle("Choose");
   menu.add(Menu.NONE, 1, 0, "Copy");
   menu.add(Menu.NONE, 2, 1, "Share");
 }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    // Inflate the menu from xml.
    getMenuInflater().inflate(R.menu.time_schedule_context_menu, menu);

    // Use the current item to create a custom view for the header.
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    final Cursor c = (Cursor) mScheduleList.getAdapter().getItem((int) info.position);
    final TimeSchedule schedule = new TimeSchedule(c);

    // Construct the Calendar to compute the time.
    final Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, schedule.hour);
    cal.set(Calendar.MINUTE, schedule.minutes);
    final String time = TimeSchedule.formatTime(this, cal);

    // Inflate the custom view and set each TextView's text.
    final View v = mInflater.inflate(R.layout.context_menu_header, null);
    TextView textView = (TextView) v.findViewById(R.id.header_time);
    textView.setText(time);
    textView = (TextView) v.findViewById(R.id.header_mode);

    textView.setText(OBS.getInstance().getModeDbAdapter().getModeNameStr(schedule.modeId));

    // Set the custom view on the menu.
    menu.setHeaderView(v);
    // Change the text based on the state of the schedule.
    if (schedule.enabled) {
      menu.findItem(R.id.enable_schedule).setTitle(R.string.disable_schedule);
    }
  }
예제 #10
0
  protected void createFileMenu(final ContextMenu menu, final String path) {
    final BookSettings bs = SettingsManager.getBookSettings(path);
    final MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.book_menu, menu);
    menu.setHeaderTitle(path);
    menu.findItem(R.id.bookmenu_recentgroup).setVisible(bs != null);
    menu.findItem(R.id.bookmenu_openbookshelf).setVisible(false);
    menu.findItem(R.id.bookmenu_openbookfolder).setVisible(false);

    final MenuItem om = menu.findItem(R.id.bookmenu_open);
    final SubMenu osm = om != null ? om.getSubMenu() : null;
    if (osm == null) {
      return;
    }
    osm.clear();

    final List<Bookmark> list = new ArrayList<Bookmark>();
    list.add(new Bookmark(true, getString(R.string.bookmark_start), PageIndex.FIRST, 0, 0));
    list.add(new Bookmark(true, getString(R.string.bookmark_end), PageIndex.LAST, 0, 1));
    if (bs != null) {
      if (LengthUtils.isNotEmpty(bs.bookmarks)) {
        list.addAll(bs.bookmarks);
      }
      list.add(
          new Bookmark(
              true, getString(R.string.bookmark_current), bs.currentPage, bs.offsetX, bs.offsetY));
    }

    Collections.sort(list);
    for (final Bookmark b : list) {
      addBookmarkMenuItem(osm, b);
    }
  }
예제 #11
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo info) {
    super.onCreateContextMenu(menu, view, info);
    final int viewId = view.getId();

    if (viewId == R.id.type) {
      for (final int typeOne : types) {
        menu.add(viewId, typeOne, 0, cgBase.logTypes2.get(typeOne));
        Log.w(cgSettings.tag, "Addig " + typeOne + " " + cgBase.logTypes2.get(typeOne));
      }
    } else if (viewId == R.id.changebutton) {
      final int textId = ((TextView) findViewById(viewId)).getId();

      menu.setHeaderTitle(res.getString(R.string.log_tb_changeall));
      for (final int logTbAction : cgBase.logTypesTrackable.keySet()) {
        menu.add(textId, logTbAction, 0, cgBase.logTypesTrackable.get(logTbAction));
      }
    } else {
      final int realViewId = ((LinearLayout) findViewById(viewId)).getId();

      for (final cgTrackableLog tb : trackables) {
        if (tb.id == realViewId) {
          menu.setHeaderTitle(tb.name);
        }
      }
      for (final int logTbAction : cgBase.logTypesTrackable.keySet()) {
        menu.add(realViewId, logTbAction, 0, cgBase.logTypesTrackable.get(logTbAction));
      }
    }
  }
예제 #12
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo info) {
    super.onCreateContextMenu(menu, v, info);

    boolean multi_data = handler.hasMultiSelectData();
    AdapterContextMenuInfo _info = (AdapterContextMenuInfo) info;
    selected_list_item = handler.getData(_info.position);

    if (flmg.isDirectory(selected_list_item)) {
      menu.setHeaderTitle("Folder operations");
      menu.add(0, D_MENU_DELETE, 0, "Delete Folder");
      menu.add(0, D_MENU_RENAME, 0, "Rename Folder");
      menu.add(0, D_MENU_COPY, 0, "Copy Folder");
      menu.add(0, D_MENU_ZIP, 0, "Zip Folder");
      menu.add(0, D_MENU_PASTE, 0, "Paste into folder").setEnabled(holding_file || multi_data);
      menu.add(0, D_MENU_UNZIP, 0, "Extract here").setEnabled(holding_zip);

    } else {
      menu.setHeaderTitle("File Operations");
      menu.add(0, F_MENU_DELETE, 0, "Delete File");
      menu.add(0, F_MENU_RENAME, 0, "Rename File");
      menu.add(0, F_MENU_COPY, 0, "Copy File");
      menu.add(0, F_MENU_ATTACH, 0, "Email File");
    }
  }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    final SipProfile account = profileFromContextMenuInfo(menuInfo);
    if (account == null) {
      return;
    }
    WizardInfo wizardInfos = WizardUtils.getWizardClass(account.wizard);

    // Setup the menu header
    menu.setHeaderTitle(account.display_name);
    if (wizardInfos != null) {
      menu.setHeaderIcon(wizardInfos.icon);
    }

    menu.add(
        0,
        MENU_ITEM_ACTIVATE,
        0,
        account.active ? R.string.deactivate_account : R.string.activate_account);
    menu.add(0, MENU_ITEM_MODIFY, 0, R.string.modify_account);
    menu.add(0, MENU_ITEM_DELETE, 0, R.string.delete_account);
    if (!VoXMobile.isVoXMobile(account.proxies)) {
      menu.add(0, MENU_ITEM_WIZARD, 0, R.string.choose_wizard);
    }
  }
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
   menu.add(0, v.getId(), 0, "Move");
   menu.add(0, v.getId(), 0, "Rename");
   menu.add(0, v.getId(), 0, "Set Description");
   menu.add(0, v.getId(), 0, "Upload Track to Dropbox");
   menu.add(0, v.getId(), 0, "Delete");
 }
예제 #15
0
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   menu.add(Menu.NONE, MenuId.RENAME.getId(), Menu.NONE, getString(R.string.s_Rename));
   menu.add(Menu.NONE, MenuId.DELETE.getId(), Menu.NONE, getString(R.string.s_Delete));
   menu.add(Menu.NONE, MenuId.DECOMPILE.getId(), Menu.NONE, getString(R.string.s_Decompile));
   menu.add(Menu.NONE, MenuId.BUILD.getId(), Menu.NONE, getString(R.string.s_Build));
 }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo info) {
    super.onCreateContextMenu(menu, view, info);
    final int viewId = view.getId();

    if (viewId == R.id.type) {
      for (final LogType typeOne : possibleLogTypes) {
        menu.add(viewId, typeOne.id, 0, typeOne.getL10n());
        Log.w("Adding " + typeOne + " " + typeOne.getL10n());
      }
    } else if (viewId == R.id.changebutton) {
      final int textId = ((TextView) findViewById(viewId)).getId();

      menu.setHeaderTitle(res.getString(R.string.log_tb_changeall));
      for (LogTypeTrackable logType : LogTypeTrackable.values()) {
        menu.add(textId, logType.id, 0, res.getString(logType.resourceId));
      }
    } else {
      final int realViewId = ((LinearLayout) findViewById(viewId)).getId();

      for (final cgTrackableLog tb : trackables) {
        if (tb.id == realViewId) {
          menu.setHeaderTitle(tb.name);
        }
      }
      for (LogTypeTrackable logType : LogTypeTrackable.values()) {
        menu.add(realViewId, logType.id, 0, res.getString(logType.resourceId));
      }
    }
  }
예제 #17
0
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   menu.add(0, DELETE_ID, 0, R.string.menu_delete);
   menu.add(0, EDIT_ID, 0, R.string.edit_note);
   menu.add(0, TEXT_ID, 0, R.string.send_text);
 }
예제 #18
0
 /* Set up context menus for script list */
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   menu.add(0, EDIT_MENU, 0, R.string.Menu_edit);
   menu.add(0, EXECUTE_MENU, 0, R.string.Menu_run);
   menu.add(0, DELETE_MENU, 0, R.string.Menu_delete);
 }
예제 #19
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    // Inflate the menu from xml.
    getMenuInflater().inflate(R.menu.context_menu, menu);

    // Use the current item to create a custom view for the header.
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    final Cursor c = (Cursor) mAlarmsList.getAdapter().getItem(info.position);
    final Alarm alarm = new Alarm(c);

    // Construct the Calendar to compute the time.
    final Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, alarm.hour);
    cal.set(Calendar.MINUTE, alarm.minutes);
    final String time = Alarms.formatTime(this, cal);

    // Inflate the custom view and set each TextView's text.
    final View v = mFactory.inflate(R.layout.context_menu_header, null);
    TextView textView = (TextView) v.findViewById(R.id.header_time);
    textView.setText(time);
    textView = (TextView) v.findViewById(R.id.header_label);
    textView.setText(alarm.label);

    // Set the custom view on the menu.
    menu.setHeaderView(v);
    // Change the text based on the state of the alarm.
    if (alarm.enabled) {
      menu.findItem(R.id.enable_alarm).setTitle(R.string.disable_alarm);
    }
  }
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   menu.setHeaderTitle("select action");
   menu.add(0, v.getId(), 0, "update");
   menu.add(0, v.getId(), 0, "delete");
 }
예제 #21
0
  public void onCreateContextMenu(ContextMenu menu) {
    super.onCreateContextMenu(menu);

    menu.setHeaderTitle("MyImage Menu");
    menu.add(0, 100, 0, "이미지 회전");
    menu.add(0, 101, 0, "크기 변경");
  }
예제 #22
0
파일: BookmarksDlg.java 프로젝트: pesgh/cr3
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   MenuInflater inflater = mCoolReader.getMenuInflater();
   menu.clear();
   inflater.inflate(
       mList.isShortcutMode()
           ? R.menu.cr3_bookmark_shortcut_context_menu
           : R.menu.cr3_bookmark_context_menu,
       menu);
   AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
   if (mi != null) selectedItem = mi.position;
   Bookmark bm = mList.getSelectedBookmark();
   menu.setHeaderTitle(getContext().getString(R.string.context_menu_title_bookmark));
   for (int i = 0; i < menu.size(); i++) {
     MenuItem menuItem = menu.getItem(i);
     if (menuItem.getItemId() == R.id.bookmark_shortcut_goto
         || menuItem.getItemId() == R.id.bookmark_edit
         || menuItem.getItemId() == R.id.bookmark_delete) menuItem.setEnabled(bm != null);
     if (menuItem.getItemId() == R.id.bookmark_edit)
       menuItem.setEnabled(
           bm != null
               && (bm.getType() == Bookmark.TYPE_COMMENT
                   || bm.getType() == Bookmark.TYPE_CORRECTION));
     menuItem.setOnMenuItemClickListener(
         new OnMenuItemClickListener() {
           public boolean onMenuItemClick(MenuItem item) {
             onContextItemSelected(item);
             return true;
           }
         });
   }
 }
 /** creates the context menu for items when they get a long click */
 @Override
 public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, view, menuInfo);
   menu.add(0, SET_STOP_OPTION, SET_STOP_OPTION, "Set alarm for this stop");
   menu.add(0, REMOVE_STOP_OPTION, REMOVE_STOP_OPTION, "Remove this stop");
   menu.add(0, CANCEL, CANCEL, "Cancel");
 }
  @Override
  public void buildContextMenu(ContextMenu menu, XbmcRequester requester) {

    //		intent.putExtra("FOLDER", getFilePath());
    //
    //		intent.putExtra("MEDIA_TYPE", getPlaylistId());
    //
    //		intent.putExtra("TYPE", getType());
    //
    MenuItem playItem = menu.add(R.string.play);
    Intent intent = new Intent();
    intent.putExtra("WHERECLAUSE", "idEpisode = " + idEpisode);
    intent.putExtra("EXEC_MODE", execModeEnum.Play);
    playItem.setIntent(intent);
    playItem.setOnMenuItemClickListener(new playVideoSelectionMenuItemClickListener());
    //
    playItem = menu.add(R.string.enqueue);
    Intent intent2 = new Intent();
    intent2.putExtra("EXEC_MODE", execModeEnum.Enqueue);
    intent2.putExtra("WHERECLAUSE", "idEpisode = " + idEpisode);

    playItem.setIntent(intent2);
    playItem.setOnMenuItemClickListener(new playVideoSelectionMenuItemClickListener());

    playItem = menu.add(R.string.clear_playlist);
    playItem.setOnMenuItemClickListener(new ClearPlaylistMenuItemClickListener());
  }
예제 #25
0
  @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);
  }
예제 #26
0
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   menu.setHeaderTitle("Select action");
   menu.add(1, 1001, 1, "Call");
   menu.add(1, 1002, 2, "SMS");
 }
예제 #27
0
 public final boolean a(ContextMenu paramContextMenu, View paramView, ai paramai) {
   if (ah.tE().isSDCardAvailable()) {
     int i = getTagposition;
     Object localObject = null;
     if (field_msgId > 0L) {
       localObject = n.Ay().ae(field_msgId);
     }
     if (((localObject == null) || (bJz <= 0L)) && (field_msgSvrId > 0L)) {
       n.Ay().ad(field_msgSvrId);
     }
     paramContextMenu.add(i, 110, 0, paramView.getContext().getString(2131234525));
     if ((com.tencent.mm.v.o.xl()) && (!ltl.bln())) {
       paramContextMenu.add(i, 114, 0, paramView.getContext().getString(2131231696));
     }
     if (com.tencent.mm.av.c.zM("favorite")) {
       paramContextMenu.add(i, 116, 0, paramView.getContext().getString(2131234160));
     }
     localObject = new bz();
     ahe.agU = field_msgId;
     com.tencent.mm.sdk.c.a.kug.y((b) localObject);
     if ((ahf.agF) || (g.u(ltl.kNN.kOg, field_type))) {
       paramContextMenu.add(i, 128, 0, paramView.getContext().getString(2131231704));
     }
     if (!ltl.bln()) {
       paramContextMenu.add(i, 100, 0, paramView.getContext().getString(2131231699));
     }
   }
   return true;
 }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == R.id.layout_apps_list) {
      final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
      Application app = listApps.get(info.position);
      if (app.getName() == null) {
        menu.setHeaderTitle("Unknown application");
      } else {
        menu.setHeaderTitle(app.getName());
      }
      MenuItem menuItem = menu.add(Menu.NONE, MENUITEM_DETAILS, MENUITEM_DETAILS, "Details");
      menuItem.setOnMenuItemClickListener(
          new OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
              editApplication(info.position);
              return true;
            }
          });
      menuItem = menu.add(Menu.NONE, MENUITEM_DELETE, MENUITEM_DELETE, "Delete");
      menuItem.setOnMenuItemClickListener(
          new OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
              deleteApplication(info.position);
              return true;
            }
          });
    }
  }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    itemposition = info.position;
    if (itemposition > 0) itemposition--; // hay que restar 1 porque la lista tiene un header

    Comment comment = listaComments.get(itemposition);
    // Cuando pulsamos nos aparece como título la fecha y la hora para saber cual seleccionamos
    final int MAXLENGHT = 10;
    String txt = comment.getTxt();
    if (txt.length() > MAXLENGHT) { // truncamos por la longitud maxima
      txt = txt.substring(0, MAXLENGHT) + " ...";
    }
    menu.setHeaderTitle(comment.getUsername() + " : \"" + txt + "\"");

    byte[] img = comment.getImage();
    if (img != null) {
      ByteArrayInputStream is = new ByteArrayInputStream(img);
      menu.setHeaderIcon(Drawable.createFromStream(is, "image"));
    }

    // si somos supervaca o somos los dueños del mensaje
    if ((BuildConfig.SUPERAPP) || (comment.getDevid() == Utilidades.getDevId(getActivity()))) {
      menu.add(
          FRAGMENT_GROUPID,
          R.id.action_borrar_comentario,
          0,
          "Borrar comentario"); // podremos borrar
    }
  }
예제 #30
0
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {

    super.onCreateContextMenu(menu, v, menuInfo);

    ExpandableListView.ExpandableListContextMenuInfo info =
        (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);

    int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);

    int child = ExpandableListView.getPackedPositionChild(info.packedPosition);

    Cursor parentCursor =
        ((MyExpandableListAdapter) expandableListView.getExpandableListAdapter()).getCursor();
    parentCursor.moveToPosition(group);

    selectedParentRowId =
        parentCursor.getString(parentCursor.getColumnIndexOrThrow(FoodsWeightDBAdapter.KEY_ROWID));
    selectedParentName =
        parentCursor.getString(parentCursor.getColumnIndexOrThrow(FoodsWeightDBAdapter.KEY_NAME));

    // Create a context menu for child items
    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
      Cursor childCursor =
          ((MyExpandableListAdapter) expandableListView.getExpandableListAdapter())
              .getChildrenCursor(parentCursor);
      childCursor.moveToPosition(child);

      selectedChildRowId =
          parentCursor.getString(childCursor.getColumnIndexOrThrow(FoodsWeightDBAdapter.KEY_ROWID));
      selectedChildName =
          childCursor.getString(childCursor.getColumnIndexOrThrow(FoodsWeightDBAdapter.KEY_NAME));
      selectedChildGlass =
          childCursor.getString(childCursor.getColumnIndexOrThrow(FoodsWeightDBAdapter.KEY_GLASS));
      selectedChildSpoon =
          childCursor.getString(childCursor.getColumnIndexOrThrow(FoodsWeightDBAdapter.KEY_SPOON));
      selectedChildPcs =
          childCursor.getString(childCursor.getColumnIndexOrThrow(FoodsWeightDBAdapter.KEY_PCS));

      menu.setHeaderTitle(
          "<<" + selectedParentName + ">>" + Character.toString((char) 10) + selectedChildName);

      for (int i = 0; i < menuItems.length; i++) {
        menu.add(Menu.NONE, i, i, menuItems[i]);
      }
    }

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {

      selectedChildRowId = "-1";
      Log.i(getTag(), "group = " + group + " child = " + child);
      menu.setHeaderTitle(selectedParentName);

      for (int i = 0; i < menuItems.length; i++) {
        menu.add(Menu.NONE, i, i, menuItems[i]);
      }
    }
  }