コード例 #1
0
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

    Intent i;

    switch (item.getItemId()) {
      case MENU_OPEN_IN_TAB:
        i = new Intent();
        i.putExtra(Constants.EXTRA_ID_NEW_TAB, true);
        i.putExtra(Constants.EXTRA_ID_URL, mDbAdapter.getBookmarkById(info.id)[1]);
        setResult(RESULT_OK, i);
        finish();
        return true;

      case MENU_EDIT_BOOKMARK:
        i = new Intent(this, EditBookmarkActivity.class);
        i.putExtra(Constants.EXTRA_ID_BOOKMARK_ID, info.id);
        i.putExtra(Constants.EXTRA_ID_BOOKMARK_TITLE, mDbAdapter.getBookmarkById(info.id)[0]);
        i.putExtra(Constants.EXTRA_ID_BOOKMARK_URL, mDbAdapter.getBookmarkById(info.id)[1]);

        startActivityForResult(i, ACTIVITY_EDIT_BOOKMARK);
        return true;

      case MENU_DELETE_BOOKMARK:
        mDbAdapter.deleteBookmark(info.id);
        fillData();
        return true;
      default:
        return super.onContextItemSelected(item);
    }
  }
コード例 #2
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    Intent result = new Intent();
    result.putExtra(Constants.EXTRA_ID_NEW_TAB, false);
    result.putExtra(Constants.EXTRA_ID_URL, mDbAdapter.getBookmarkById(id)[1]);

    setResult(RESULT_OK, result);
    finish();
  }
コード例 #3
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    long id = ((AdapterContextMenuInfo) menuInfo).id;
    if (id != -1) {
      menu.setHeaderTitle(mDbAdapter.getBookmarkById(id)[0]);
    }

    menu.add(0, MENU_OPEN_IN_TAB, 0, R.string.BookmarksListActivity_MenuOpenInTab);
    menu.add(0, MENU_EDIT_BOOKMARK, 0, R.string.BookmarksListActivity_MenuEditBookmark);
    menu.add(0, MENU_DELETE_BOOKMARK, 0, R.string.BookmarksListActivity_MenuDeleteBookmark);
  }