Esempio n. 1
0
 @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;
           }
         });
   }
 }
Esempio n. 2
0
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
   if (v.equals(findViewById(R.id.phone_main))) {
     menu.clear();
     int pos = 0;
     for (String title : getHomeFragment().getAdapter().getTitles()) {
       menu.add(MAIN_ACTIVITY_CONTEXT_GROUP, pos++, (pos - 1), title);
     }
   }
 }
Esempio n. 3
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (menu.size() > 0) {
      menu.clear();
    }

    // view holder
    if (v.getTag() != null) {
      adapter.onCreateContextMenu(menu, v);
    }
  }
 /* (non-Javadoc)
  * @see android.view.View.OnCreateContextMenuListener#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)
  */
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   if (mResideMenu != null && mResideMenu.isOpened()) {
     return;
   }
   AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
   int pos = info.position;
   menu.clear();
   menu.setHeaderTitle("选项:");
   String filePath = (String) mAdapter.getItem(pos);
   ListMenuClickListener mListMenuClickListener =
       new ListMenuClickListener(mContext, filePath, mFileType);
   menu.add(0, AppUtils.MENU_DELETE, 0, "删除").setOnMenuItemClickListener(mListMenuClickListener);
   menu.add(0, AppUtils.MENU_SHOW, 0, "查看").setOnMenuItemClickListener(mListMenuClickListener);
 }
Esempio n. 5
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menu_info) {
    menu.clear();

    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menu_info;
    long packed_pos = info.packedPosition;

    if (ExpandableListView.getPackedPositionType(packed_pos)
        == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
      int group_pos = ExpandableListView.getPackedPositionGroup(packed_pos);
      int child_pos = ExpandableListView.getPackedPositionChild(packed_pos);
      BoardData data = (BoardData) list_adapter_.getChild(group_pos, child_pos);
      if (data == null) return;
      if (data.id_ != 0) {
        menu.setHeaderTitle(R.string.ctx_menu_title_board);
        menu.add(0, CTX_MENU_DELETE_BOARD, CTX_MENU_DELETE_BOARD, R.string.ctx_menu_delete_board);
        menu.add(0, CTX_MENU_EDIT_BOARD, CTX_MENU_EDIT_BOARD, R.string.ctx_menu_edit_board);
      }
    }
  }