Java 类android.view.ContextMenu.ContextMenuInfo 实例源码

项目:yaacc-code    文件:ContentListActivity.java   
/**
 * Creates context menu for certain actions on a specific item.
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    if (v instanceof ListView) {
        ListView listView = (ListView) v;
        Object item = listView.getAdapter().getItem(info.position);
        if (item instanceof DIDLObject) {
            selectedDIDLObject = (DIDLObject) item;
        }
    }
    menu.setHeaderTitle(v.getContext().getString(
            R.string.browse_context_title));
    ArrayList<String> menuItems = new ArrayList<String>();
    menuItems.add(v.getContext().getString(R.string.browse_context_play_all));
    menuItems.add(v.getContext().getString(R.string.browse_context_play));
    //menuItems.add(v.getContext().getString( R.string.browse_context_add_to_playplist));
    menuItems.add(v.getContext()
            .getString(R.string.browse_context_download));
    for (int i = 0; i < menuItems.size(); i++) {
        menu.add(Menu.NONE, i, i, menuItems.get(i));
    }
}
项目:CSipSimple    文件:CodecsFragment.java   
@Override
@SuppressWarnings("unchecked")
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info;
    try {
         info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(THIS_FILE, "bad menuInfo", e);
        return;
    }

    HashMap<String, Object> codec = (HashMap<String, Object>) mAdapter.getItem(info.position);
    if (codec == null) {
        // If for some reason the requested item isn't available, do nothing
        return;
    }

    boolean isDisabled = ((Short)codec.get(CODEC_PRIORITY) == 0);
    menu.add(0, MENU_ITEM_ACTIVATE, 0, isDisabled ? R.string.activate : R.string.deactivate);

}
项目:CSipSimple    文件:AccountsEditListFragment.java   
/**
 * Retrieve sip account from a given context menu info pressed
 * @param cmi The context menu info to retrieve infos from
 * @return corresponding sip profile if everything goes well, null if not able to retrieve profile
 */
private SipProfile profileFromContextMenuInfo(ContextMenuInfo cmi) {
    AdapterView.AdapterContextMenuInfo info;
    try {
        info = (AdapterView.AdapterContextMenuInfo) cmi;
    } catch (ClassCastException e) {
        Log.e(THIS_FILE, "bad menuInfo", e);
        return null;
    }
    Cursor c = (Cursor) getListAdapter().getItem(info.position - getListView().getHeaderViewsCount());
    if (c == null) {
        // For some reason the requested item isn't available, do nothing
        return null;
    }
    return new SipProfile(c);
}
项目:CSipSimple    文件:AccountsEditListFragment.java   
@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);
    menu.add(0, MENU_ITEM_WIZARD, 0, R.string.choose_wizard);

}
项目:chromium-for-android-56-debug-video    文件:RecentTabsPage.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    // Would prefer to have this context menu view managed internal to RecentTabsGroupView
    // Unfortunately, setting either onCreateContextMenuListener or onLongClickListener
    // disables the native onClick (expand/collapse) behaviour of the group view.
    ExpandableListView.ExpandableListContextMenuInfo info =
            (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

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

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        mAdapter.getGroup(groupPosition).onCreateContextMenuForGroup(menu, mActivity);
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
        mAdapter.getGroup(groupPosition).onCreateContextMenuForChild(childPosition, menu,
                mActivity);
    }
}
项目:financisto1-holo    文件:AbstractListActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterView.AdapterContextMenuInfo mi = (AdapterView.AdapterContextMenuInfo)menuInfo;
    String headerTitle = getContextMenuHeaderTitle(mi.position);
    if (headerTitle != null) {
        menu.setHeaderTitle(headerTitle);
    }
    List<MenuItemInfo> menus = createContextMenus(mi.id);
    int i = 0;
    for (MenuItemInfo m : menus) {
        if (m.enabled) {
            menu.add(0, m.menuId, i++, m.titleId);              
        }
    }
}
项目:exciting-app    文件:ExpandableHListView.java   
@Override
ContextMenuInfo createContextMenuInfo( View view, int flatListPosition, long id ) {
    if( isHeaderOrFooterPosition( flatListPosition ) ) {
        // Return normal info for header/footer view context menus
        return new AdapterContextMenuInfo( view, flatListPosition, id );
    }

    final int adjustedPosition = getFlatPositionForConnector( flatListPosition );
    ExpandableHListConnector.PositionMetadata pm = mConnector.getUnflattenedPos( adjustedPosition );
    ExpandableHListPosition pos = pm.position;

    id = getChildOrGroupId( pos );
    long packedPosition = pos.getPackedPosition();

    pm.recycle();

    return new ExpandableListContextMenuInfo( view, packedPosition, id );
}
项目:aos-Video    文件:AutoScraperActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);

    // Show the name of the file in the header
    AdapterContextMenuInfo adapterMenuInfo = (AdapterContextMenuInfo)menuInfo;
    int position = adapterMenuInfo.position;
    mActivityFileCursor.moveToPosition(position);
    String path = mActivityFileCursor.getString(mDataIndex);
    MetaFile file = MetaFile.from(path);
    menu.setHeaderTitle(file.getName());

    // Add the context menu items
    menu.add(0, R.string.info, 0, R.string.info);

    // Save the path, we will need it when an entry of the menu is selected
    mContextMenuPath = path;
}
项目:buildAPKsSamples    文件:AccountsActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
    ContextMenuInfo menuInfo) {
  if (v.getId() != R.id.accounts_list) {
    return;
  }

  AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
  Account account = (Account) adapter.getItem(info.position);
  menu.setHeaderTitle(account.toString());

  String[] menuItems = getResources().getStringArray(R.array.account_actions);
  for (int i = 0; i < menuItems.length; i++) {
    menu.add(Menu.NONE, i, i, menuItems[i]);
  }
}
项目:encdroidMC    文件:EDVolumeListActivity.java   
public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.volume_list_context, menu);

    // Change the text of the lock/unlock item based on volume status
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    EDVolume selected = mAdapter.getItem((int) info.id);

    MenuItem lockItem = menu.findItem(R.id.volume_list_menu_lock);

    if (selected.isLocked()) {
        lockItem.setTitle(getString(R.string.menu_unlock_volume));
    } else {
        lockItem.setTitle(getString(R.string.menu_lock_volume));
    }
}
项目:microMathematics    文件:Commander.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
    try
    {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        if (info != null)
        {
            fileListView.setSelection(info.position, 0);
        }
        menu.setHeaderTitle(R.string.fman_operation);
        AdapterIf ca = getListAdapter();
        ca.populateContextMenu(menu, info, fileListView.getSelected());
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
项目:SmartMath    文件:ActivityCfgKeyPad.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {  
    super.onCreateContextMenu(menu, v, menuInfo);
    if (v.getTag() instanceof InputKeyReference)    {
        menu.setHeaderTitle(R.string.what_do_you_want);
        menu.add(0, KEY_CONTEXT_MENU_CUT, 0, R.string.cut_key);  
        menu.add(0, KEY_CONTEXT_MENU_COPY, 0, R.string.copy_key);  
        if (minputKeyRefClipboard.isEmpty() == false)   {
            menu.add(0, KEY_CONTEXT_MENU_PASTE_BEFORE, 0, R.string.paste_before_key);  
            menu.add(0, KEY_CONTEXT_MENU_PASTE_ON, 0, R.string.paste_on_key);
            menu.add(0, KEY_CONTEXT_MENU_PASTE_AFTER, 0, R.string.paste_after_key);
        }
        menu.add(0, KEY_CONTEXT_MENU_CREATE_BEFORE, 0, R.string.create_before_key);  
        menu.add(0, KEY_CONTEXT_MENU_CREATE_AFTER, 0, R.string.create_after_key);  
        menu.add(0, KEY_CONTEXT_MENU_DELETE, 0, R.string.delete_key);  
        menu.add(0, KEY_CONTEXT_MENU_EDIT, 0, R.string.edit_key); 
        // should not use assign, i.e. minputKeyRefUnderOpt = v.getTag()
        // cause minputKeyRefUnderOpt and tag may change in different scenarios
        minputKeyRefUnderOpt.copy((InputKeyReference) v.getTag());
    }
}
项目:q-mail    文件:FolderList.java   
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    getMenuInflater().inflate(R.menu.folder_context, menu);

    FolderInfoHolder folder = (FolderInfoHolder) mAdapter.getItem(info.position);

    menu.setHeaderTitle(folder.displayName);
}
项目:q-mail    文件:Accounts.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle(R.string.accounts_context_menu_title);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    BaseAccount account =  mAdapter.getItem(info.position);

    if ((account instanceof Account) && !((Account) account).isEnabled()) {
        getMenuInflater().inflate(R.menu.disabled_accounts_context, menu);
    } else {
        getMenuInflater().inflate(R.menu.accounts_context, menu);
    }

    if (account instanceof SearchAccount) {
        for (int i = 0; i < menu.size(); i++) {
            android.view.MenuItem item = menu.getItem(i);
                item.setVisible(false);
        }
    }
    else {
        EnumSet<ACCOUNT_LOCATION> accountLocation = accountLocation(account);
        if (accountLocation.contains(ACCOUNT_LOCATION.TOP)) {
            menu.findItem(R.id.move_up).setEnabled(false);
        }
        else {
            menu.findItem(R.id.move_up).setEnabled(true);
        }
        if (accountLocation.contains(ACCOUNT_LOCATION.BOTTOM)) {
            menu.findItem(R.id.move_down).setEnabled(false);
        }
        else {
            menu.findItem(R.id.move_down).setEnabled(true);
        }
    }
}
项目:PeSanKita-android    文件:VerifyIdentityActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View view,
                                ContextMenuInfo menuInfo)
{
  super.onCreateContextMenu(menu, view, menuInfo);

  MenuInflater inflater = getActivity().getMenuInflater();
  inflater.inflate(R.menu.verify_display_fragment_context_menu, menu);

}
项目:CSipSimple    文件:AccountFiltersListFragment.java   
/**
 * Retrieve filter id from a given context menu info pressed
 * @param cmi The context menu info to retrieve infos from
 * @return corresponding filter id if everything goes well, -1 if not able to retrieve filter
 */
private long filterIdFromContextMenuInfo(ContextMenuInfo cmi) {
    AdapterView.AdapterContextMenuInfo info;
    try {
        info = (AdapterView.AdapterContextMenuInfo) cmi;
    } catch (ClassCastException e) {
        Log.e(THIS_FILE, "bad menuInfo", e);
        return -1;
    }
    return info.id;
}
项目:CSipSimple    文件:AccountFiltersListFragment.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    final long filterId = filterIdFromContextMenuInfo(menuInfo);
    if(filterId == -1) {
        return;
    }

    menu.add(0, MENU_ITEM_MODIFY, 0, R.string.edit);
    menu.add(0, MENU_ITEM_DELETE, 0, R.string.delete_filter);

}
项目:open-rmbt    文件:RMBTSyncRequestCodeFragment.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo contextMenuInfo)
{
    if (view instanceof TextView && view == codeText)
        menu.add(Menu.NONE, view.getId(), Menu.NONE, R.string.sync_request_code_context_copy);
    else
        super.onCreateContextMenu(menu, view, contextMenuInfo);
}
项目:chromium-for-android-56-debug-video    文件:ContextMenuHelper.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    assert mPopulator != null;
    mPopulator.buildContextMenu(menu, v.getContext(), mCurrentContextMenuParams);

    for (int i = 0; i < menu.size(); i++) {
        menu.getItem(i).setOnMenuItemClickListener(this);
    }
}
项目:buildAPKsApps    文件:Trolly.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info;
       try {
            info = (AdapterView.AdapterContextMenuInfo) menuInfo;
       } catch (ClassCastException e) {
           return;
       }
    Cursor cursor = (Cursor)getListAdapter().getItem(info.position);
    if (cursor == null) {
           // For some reason the requested item isn't available, do nothing
           return;
       }
       // Setup the menu header
       menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex(ShoppingList.ITEM)));
       int status = cursor.getInt(cursor.getColumnIndex(ShoppingList.STATUS));

    //Add context menu items depending on current state
    switch (status) {
       case ShoppingList.OFF_LIST:
        menu.add(0, MENU_ITEM_ON_LIST, 0, R.string.move_on_list);
        menu.add(0, MENU_ITEM_IN_TROLLEY, 0, R.string.move_in_trolley);
        break;
       case ShoppingList.ON_LIST:
        menu.add(0, MENU_ITEM_IN_TROLLEY, 0, R.string.move_in_trolley);
        menu.add(0, MENU_ITEM_OFF_LIST, 0, R.string.move_off_list);
        break;
       case ShoppingList.IN_TROLLEY:
        menu.add(0, MENU_ITEM_ON_LIST, 0, R.string.move_on_list);
        menu.add(0, MENU_ITEM_OFF_LIST, 0, R.string.move_off_list);
        break;
       }

       // Add context menu items that are relevant for all items
    menu.add(0, MENU_ITEM_EDIT, 0, R.string.edit_item);
    menu.add(0, MENU_ITEM_DELETE, 0, R.string.delete_item);
}
项目:buildAPKsApps    文件:SimplyDoActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo)
{
    Log.v(L.TAG, "ItemsListReactor.onCreateContextMenu()");

    AdapterContextMenuInfo ctxMenuInfo = (AdapterContextMenuInfo)menuInfo;
    ListView listView = (ListView)findViewById(R.id.ItemsListView);
    ctxItem = (ItemDesc)listView.getItemAtPosition(ctxMenuInfo.position);

    menu.setHeaderTitle("Item Options");
    menu.add(Menu.NONE, EDIT_ITEM, Menu.NONE, "Edit");
    menu.add(Menu.NONE, DELETE_ITEM, Menu.NONE, "Delete");
    String toggleText;
    if(ctxItem.isStar())
    {
        toggleText = "Remove Star";
    }
    else
    {
        toggleText = "Add Star";
    }
    menu.add(Menu.NONE, TOGGLE_STAR, Menu.NONE, toggleText);
    if(dataViewer.getListData().size() > 1)
    {
        menu.add(Menu.NONE, MOVE_ITEM, Menu.NONE, "Move To");
    }
}
项目:buildAPKsApps    文件:SimplyDoActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo)
{
    Log.v(L.TAG, "ListsListReactor.onCreateContextMenu()");

    AdapterContextMenuInfo ctxMenuInfo = (AdapterContextMenuInfo)menuInfo;
    ListView listView = (ListView)findViewById(R.id.ListsListView);
    ctxList = (ListDesc)listView.getItemAtPosition(ctxMenuInfo.position);

    menu.setHeaderTitle("List Options");
    menu.add(Menu.NONE, EDIT_LIST, Menu.NONE, "Edit");
    menu.add(Menu.NONE, DELETE_LIST, Menu.NONE, "Delete");
}
项目:buildAPKsApps    文件:BarrageList.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    menu.clear();

    menu.add(0, MENU_EDIT, 0, R.string.menu_edit);
    menu.add(0, MENU_PAUSE, 0, R.string.menu_pause);
    menu.add(0, MENU_DELETE, 0, R.string.menu_delete);
}
项目:buildAPKsApps    文件:RecipientsEditor.java   
@Override
protected ContextMenuInfo getContextMenuInfo() {
    if ((mLongPressedPosition >= 0)) {
        Spanned text = getText();
        int start = mTokenizer.findTokenStart(text, mLongPressedPosition);
        int end = mTokenizer.findTokenEnd(text, start);

        if (end != start) {
            Recipient r = getRecipientAt(getText(), start, end);
            return new RecipientContextMenuInfo(r);
        }
    }
    return null;
}
项目:Huochexing12306    文件:MonitorMangAty.java   
private void setListViewContextMenuWithDel() {
    lvMang.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v,
                ContextMenuInfo menuInfo) {
            intCurrDataPos = ((AdapterContextMenuInfo) menuInfo).position;
            menu.add(0, 0, 0, "删除");
        }
    });
}
项目:Huochexing12306    文件:MonitorMangAty.java   
private void setListViewContextMenuWithDel_Resume() {
    lvMang.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v,
                ContextMenuInfo menuInfo) {
            intCurrDataPos = ((AdapterContextMenuInfo) menuInfo).position;
            menu.add(0, 0, 0, "删除");
            menu.add(0, 1, 1, "恢复所有已暂停车次");
        }
    });
}
项目:aos-Video    文件:SubtitlesWizardActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);

    AdapterContextMenuInfo adapterMenuInfo = (AdapterContextMenuInfo)menuInfo;
    mPosition = adapterMenuInfo.position;

    ItemData itemData = getItemData(mPosition);
    if (itemData.type == ITEM_DATA_TYPE_SEPARATOR || itemData.type == ITEM_DATA_TYPE_MESSAGE) {
        // No contextual menu for separators or messages
        return;
    }

    // Show the name of the file in the header
    File file = new File(itemData.path);
    menu.setHeaderTitle(file.getName());

    if (itemData.type == ITEM_DATA_TYPE_CURRENT) {
        // Contextual menu for current subtitles files
        menu.add(0, R.string.subtitles_wizard_delete, 0, R.string.subtitles_wizard_delete);
    }
    else {
        // Contextual menu for available subtitles files
        menu.add(0, R.string.subtitles_wizard_associate, 0, R.string.subtitles_wizard_associate);
        menu.add(0, R.string.subtitles_wizard_delete, 0, R.string.subtitles_wizard_delete);
    }
}
项目:aos-Video    文件:BrowserActivity.java   
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (DBG)
        Log.d(TAG, "onCreateContextMenu");
    if ((mCoverRoll != null) && v.equals(mCoverRoll)) {
        mCoverRoll.createContextMenu(this, menu);
    }
    super.onCreateContextMenu(menu, v, menuInfo);
}
项目:buildAPKsSamples    文件:Notepadv2.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

       // TODO: fill in rest of method
}
项目:android-mrz-reader    文件:CaptureActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (v.equals(ocrResultView)) {
        menu.add(Menu.NONE, OPTIONS_COPY_RECOGNIZED_TEXT_ID, Menu.NONE, "Copy recognized text");
        menu.add(Menu.NONE, OPTIONS_SHARE_RECOGNIZED_TEXT_ID, Menu.NONE, "Share recognized text");
    } else if (v.equals(translationView)) {
        menu.add(Menu.NONE, OPTIONS_COPY_TRANSLATED_TEXT_ID, Menu.NONE, "Copy translated text");
        menu.add(Menu.NONE, OPTIONS_SHARE_TRANSLATED_TEXT_ID, Menu.NONE, "Share translated text");
    }
}
项目:encdroidMC    文件:EDFileChooserActivity.java   
public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getMenuInflater();
    if (mMode == FILE_PICKER_MODE) {
        inflater.inflate(R.menu.file_picker_context, menu);
    } else {
        inflater.inflate(R.menu.file_chooser_context, menu);
    }
}
项目:firebase-testlab-instr-lib    文件:NotesList.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info;
    try {
         info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(TAG, "bad menuInfo", e);
        return;
    }

    Cursor cursor = (Cursor) getListAdapter().getItem(info.position);
    if (cursor == null) {
        // For some reason the requested item isn't available, do nothing
        return;
    }

    // Inflate menu from XML resource
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.list_context_menu, menu);

    // Set the context menu header
    menu.setHeaderTitle(cursor.getString(COLUMN_INDEX_TITLE));

    // Append to the
    // menu items for any other activities that can do stuff with it
    // as well.  This does a query on the system for any activities that
    // implement the ALTERNATIVE_ACTION for our data, adding a menu item
    // for each one that is found.
    Intent intent = new Intent(null, Uri.withAppendedPath(getIntent().getData(), 
                                    Integer.toString((int) info.id) ));
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
    menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0,
            new ComponentName(this, NotesList.class), null, intent, 0, null);
}
项目:XPrivacy    文件:ActivityApp.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    // Check if running
    boolean running = false;
    ActivityManager activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
    for (RunningAppProcessInfo info : activityManager.getRunningAppProcesses())
        if (info.uid == mAppInfo.getUid())
            running = true;

    PackageManager pm = getPackageManager();
    List<String> listPackageNames = mAppInfo.getPackageName();
    List<String> listApplicationName = mAppInfo.getApplicationName();
    for (int i = 0; i < listPackageNames.size(); i++) {
        Menu appMenu = (listPackageNames.size() == 1) ? menu : menu.addSubMenu(i, Menu.NONE, Menu.NONE,
                listApplicationName.get(i));

        // Launch
        MenuItem launch = appMenu.add(i, MENU_LAUNCH, Menu.NONE, getString(R.string.menu_app_launch));
        if (pm.getLaunchIntentForPackage(listPackageNames.get(i)) == null)
            launch.setEnabled(false);

        // Settings
        appMenu.add(i, MENU_SETTINGS, Menu.NONE, getString(R.string.menu_app_settings));

        // Kill
        MenuItem kill = appMenu.add(i, MENU_KILL, Menu.NONE, getString(R.string.menu_app_kill));
        kill.setEnabled(running && PrivacyManager.isApplication(mAppInfo.getUid()));

        // Play store
        MenuItem store = appMenu.add(i, MENU_STORE, Menu.NONE, getString(R.string.menu_app_store));
        if (!Util.hasMarketLink(this, listPackageNames.get(i)))
            store.setEnabled(false);
    }
}
项目:Cable-Android    文件:VerifyIdentityActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View view,
                                ContextMenuInfo menuInfo)
{
  super.onCreateContextMenu(menu, view, menuInfo);

  if (fingerprint != null) {
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.verify_display_fragment_context_menu, menu);
  }
}
项目:yaacc-code    文件:PlayerListItemClickListener.java   
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenuInfo menuInfo) {
    menu.setHeaderTitle(v.getContext().getString(R.string.browse_context_title));
    ArrayList<String> menuItems = new ArrayList<String>();
    menuItems.add(v.getContext().getString(R.string.open));
    menuItems.add(v.getContext().getString(R.string.exitActivity));

    for (int i = 0; i < menuItems.size(); i++) {
        menu.add(Menu.NONE, i, i, menuItems.get(i));
    }
}
项目:GCSApp    文件:ContactListFragment.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    toBeProcessUser = (EaseUser) listView.getItemAtPosition(((AdapterContextMenuInfo) menuInfo).position);
    toBeProcessUsername = toBeProcessUser.getUsername();
    getActivity().getMenuInflater().inflate(R.menu.em_context_contact_list, menu);
}
项目:q-mail    文件:MessageListFragment.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    Cursor cursor = (Cursor) listView.getItemAtPosition(info.position);

    if (cursor == null) {
        return;
    }

    getActivity().getMenuInflater().inflate(R.menu.message_list_item_context, menu);
    menu.findItem(R.id.debug_delete_locally).setVisible(BuildConfig.DEBUG);

    contextMenuUniqueId = cursor.getLong(uniqueIdColumn);
    Account account = getAccountFromCursor(cursor);

    String subject = cursor.getString(SUBJECT_COLUMN);
    boolean read = (cursor.getInt(READ_COLUMN) == 1);
    boolean flagged = (cursor.getInt(FLAGGED_COLUMN) == 1);

    menu.setHeaderTitle(subject);

    if (selected.contains(contextMenuUniqueId)) {
        menu.findItem(R.id.select).setVisible(false);
    } else {
        menu.findItem(R.id.deselect).setVisible(false);
    }

    if (read) {
        menu.findItem(R.id.mark_as_read).setVisible(false);
    } else {
        menu.findItem(R.id.mark_as_unread).setVisible(false);
    }

    if (flagged) {
        menu.findItem(R.id.flag).setVisible(false);
    } else {
        menu.findItem(R.id.unflag).setVisible(false);
    }

    if (!messagingController.isCopyCapable(account)) {
        menu.findItem(R.id.copy).setVisible(false);
    }

    if (!messagingController.isMoveCapable(account)) {
        menu.findItem(R.id.move).setVisible(false);
        menu.findItem(R.id.archive).setVisible(false);
        menu.findItem(R.id.spam).setVisible(false);
    }

    if (!account.hasArchiveFolder()) {
        menu.findItem(R.id.archive).setVisible(false);
    }

    if (!account.hasSpamFolder()) {
        menu.findItem(R.id.spam).setVisible(false);
    }

}
项目:q-mail    文件:ManageIdentities.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle(R.string.manage_identities_context_menu_title);
    getMenuInflater().inflate(R.menu.manage_identities_context, menu);
}
项目:GitHub    文件:FreeFlowContainer.java   
ContextMenuInfo createContextMenuInfo(View view, int sectionIndex,
        int positionInSection, long id) {
    return new AbsLayoutContainerContextMenuInfo(view, sectionIndex,
            positionInSection, id);
}
项目:CCDownload    文件:UploadFragment.java   
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    menu.setHeaderTitle("操作");
    menu.add(0, 0, 0, "删除");
}