Java 类android.widget.ExpandableListView.ExpandableListContextMenuInfo 实例源码

项目:gaeproxy    文件:HistoryListActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, 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);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {

        HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child);
        menu.setHeaderTitle(item.getTitle());

        menu.add(0, MENU_OPEN_IN_TAB, 0, R.string.HistoryListActivity_MenuOpenInTab);
        menu.add(0, MENU_COPY_URL, 0, R.string.BookmarksHistoryActivity_MenuCopyLinkUrl);
        menu.add(0, MENU_SHARE, 0, R.string.Main_MenuShareLinkUrl);
        menu.add(0, MENU_DELETE_FROM_HISTORY, 0, R.string.HistoryListActivity_MenuDelete);
    }
}
项目:zirco-browser    文件:HistoryListActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, 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);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {

        HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child);
        menu.setHeaderTitle(item.getTitle());

        menu.add(0, MENU_OPEN_IN_TAB, 0, R.string.HistoryListActivity_MenuOpenInTab);
        menu.add(0, MENU_COPY_URL, 0, R.string.BookmarksHistoryActivity_MenuCopyLinkUrl);
        menu.add(0, MENU_SHARE, 0, R.string.Main_MenuShareLinkUrl);
        menu.add(0, MENU_DELETE_FROM_HISTORY, 0, R.string.HistoryListActivity_MenuDelete);
    }
}
项目:ActivityLauncher    文件:AllTasksListFragment.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo) {
    menu.add(Menu.NONE, 0, Menu.NONE, R.string.context_action_shortcut);
    menu.add(Menu.NONE, 1, Menu.NONE, R.string.context_action_launch);

    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo)menuInfo;
    ExpandableListView list = (ExpandableListView) getView().findViewById(R.id.expandableListView1);

    switch(ExpandableListView.getPackedPositionType(info.packedPosition)) {
    case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
        MyActivityInfo activity = (MyActivityInfo) list.getExpandableListAdapter().getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition));
        menu.setHeaderIcon(activity.icon);
        menu.setHeaderTitle(activity.name);
        menu.add(Menu.NONE, 2, Menu.NONE, R.string.context_action_edit);
        break;
    case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
        MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
        menu.setHeaderIcon(pack.icon);
        menu.setHeaderTitle(pack.name);
        break;
    }

    super.onCreateContextMenu(menu, v, menuInfo);
}
项目:timetracker    文件:ListRecordingsFragment.java   
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition);
    Recording r = (Recording) recAdapter.getChild(groupPos, childPos);

    switch (item.getItemId()) {
        case R.id.action_edit:
            editRecording(r);
            return true;
        case R.id.action_delete:
            deleteRecording(r);
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
项目:ZircoBrowser    文件:HistoryListActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, 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);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {

        HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child);
        menu.setHeaderTitle(item.getTitle());

        menu.add(0, MENU_OPEN_IN_TAB, 0, R.string.HistoryListActivity_MenuOpenInTab);
        menu.add(0, MENU_COPY_URL, 0, R.string.BookmarksHistoryActivity_MenuCopyLinkUrl);
        menu.add(0, MENU_SHARE, 0, R.string.Main_MenuShareLinkUrl);
        menu.add(0, MENU_DELETE_FROM_HISTORY, 0, R.string.HistoryListActivity_MenuDelete);
    }
}
项目:dv-quiz    文件:MainActivity.java   
@Override  
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {

    super.onCreateContextMenu(menu, v, menuInfo);

    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;

    String aHeaderTitle = "";

switch (ExpandableListView.getPackedPositionType(info.packedPosition))
{
case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
    aHeaderTitle = (String) this.listAdapter.getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition)).toString();           
    break;
case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
    aHeaderTitle = (String) this.listAdapter.getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition)).toString();
    break;
default:
    break;
}

    menu.setHeaderTitle(aHeaderTitle.toString());  
    menu.add(0, CONTEXT_MENU_EDIT, 0, this.getString(R.string.edit));  
    menu.add(0, CONTEXT_MENU_DELETE, 0, this.getString(R.string.delete));  
  }
项目:ZicroBrowser    文件:HistoryListActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, 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);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {

        HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child);
        menu.setHeaderTitle(item.getTitle());

        menu.add(0, MENU_OPEN_IN_TAB, 0, R.string.HistoryListActivity_MenuOpenInTab);
        menu.add(0, MENU_COPY_URL, 0, R.string.BookmarksHistoryActivity_MenuCopyLinkUrl);
        menu.add(0, MENU_SHARE, 0, R.string.Main_MenuShareLinkUrl);
        menu.add(0, MENU_DELETE_FROM_HISTORY, 0, R.string.HistoryListActivity_MenuDelete);
    }
}
项目:gaeproxy    文件:HistoryListActivity.java   
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuItem.getMenuInfo();

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

    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        int child = ExpandableListView.getPackedPositionChild(info.packedPosition);

        HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child);

        switch (menuItem.getItemId()) {
        case MENU_OPEN_IN_TAB:
            doNavigateToUrl(item.getUrl(), true);
            break;
        case MENU_COPY_URL:
            ApplicationUtils.copyTextToClipboard(this, item.getUrl(),
                    getString(R.string.Commons_UrlCopyToastMessage));
            break;
        case MENU_SHARE:
            ApplicationUtils.sharePage(this, item.getTitle(), item.getUrl());
            break;
        case MENU_DELETE_FROM_HISTORY:
            BookmarksProviderWrapper.deleteHistoryRecord(getContentResolver(), item.getId());
            fillData();
            break;
        default:
            break;
        }
    }

    return super.onContextItemSelected(menuItem);
}
项目:appcan-plugin-pdfreader-android    文件:OPDSActivity.java   
/**
 * {@inheritDoc}
 *
 * @see android.app.Activity#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)
 */
@Override
public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
    if (menuInfo instanceof ExpandableListContextMenuInfo) {
        final ExpandableListContextMenuInfo cmi = (ExpandableListContextMenuInfo) menuInfo;
        final int type = ExpandableListView.getPackedPositionType(cmi.packedPosition);
        final int groupPosition = ExpandableListView.getPackedPositionGroup(cmi.packedPosition);
        final int childPosition = ExpandableListView.getPackedPositionChild(cmi.packedPosition);
        // System.out.println("OPDSActivity.onCreateContextMenu(): " + type + ", " + groupPosition + ", "
        // + childPosition);
        switch (type) {
            case ExpandableListView.PACKED_POSITION_TYPE_NULL:
                onCreateContextMenu(menu);
                return;
            case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
                final Entry entry = getController().adapter.getGroup(groupPosition);
                if (entry instanceof Feed) {
                    onCreateFeedContextMenu(menu, (Feed) entry);
                } else if (entry instanceof Book) {
                    onCreateBookContextMenu(menu, (Book) entry);
                }
                return;
            case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
                final Entry group = getController().adapter.getGroup(groupPosition);
                final Object child = getController().adapter.getChild(groupPosition, childPosition);
                if (child instanceof Link) {
                    onCreateLinkContextMenu(menu, (Book) group, (Link) child);
                } else if (child instanceof Feed) {
                    onCreateFacetContextMenu(menu, (Feed) group, (Feed) child);
                }
                return;
        }
    }
    onCreateContextMenu(menu);
}
项目:zirco-browser    文件:HistoryListActivity.java   
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuItem.getMenuInfo();

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

    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        int child = ExpandableListView.getPackedPositionChild(info.packedPosition);

        HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child);

        switch (menuItem.getItemId()) {
        case MENU_OPEN_IN_TAB:
            doNavigateToUrl(item.getUrl(), true);
            break;
        case MENU_COPY_URL:
            ApplicationUtils.copyTextToClipboard(this, item.getUrl(), getString(R.string.Commons_UrlCopyToastMessage));
            break;
        case MENU_SHARE:
            ApplicationUtils.sharePage(this, item.getTitle(), item.getUrl());
            break;
        case MENU_DELETE_FROM_HISTORY:
            BookmarksProviderWrapper.deleteHistoryRecord(getContentResolver(), item.getId());
            fillData();
            break;
        default:
            break;
        }
    }

    return super.onContextItemSelected(menuItem);
}
项目:timetracker    文件:ListRecordingsFragment.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

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

    //only show context menu for child items (recordings not dates)
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        MenuInflater inflater = getActivity().getMenuInflater();
        inflater.inflate(R.menu.list_recordings_context, menu);
    }
}
项目:timetracker    文件:ListTasksFragment.java   
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition);
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);

    long taskId;
    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        taskId = listHeader.get(groupPos).getId();
    } else {
        taskId = listItems.get(listHeader.get(groupPos)).get(childPos).getId();
    }


    switch (item.getItemId()) {
        case R.id.action_edit:
            editTask(taskId);
            return true;
        case R.id.action_delete:
            deleteTask(taskId);
            return true;
        case R.id.action_statistics:
            statisticsTask(taskId);
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
项目:ZircoBrowser    文件:HistoryListActivity.java   
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuItem.getMenuInfo();

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

    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        int child = ExpandableListView.getPackedPositionChild(info.packedPosition);

        HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child);

        switch (menuItem.getItemId()) {
        case MENU_OPEN_IN_TAB:
            doNavigateToUrl(item.getUrl(), true);
            break;
        case MENU_COPY_URL:
            ApplicationUtils.copyTextToClipboard(this, item.getUrl(), getString(R.string.Commons_UrlCopyToastMessage));
            break;
        case MENU_SHARE:
            ApplicationUtils.sharePage(this, item.getTitle(), item.getUrl());
            break;
        case MENU_DELETE_FROM_HISTORY:
            BookmarksProviderWrapper.deleteHistoryRecord(getContentResolver(), item.getId());
            fillData();
            break;
        default:
            break;
        }
    }

    return super.onContextItemSelected(menuItem);
}
项目:maven-yaxim    文件:MainWindow.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenu.ContextMenuInfo menuInfo) {
    ExpandableListView.ExpandableListContextMenuInfo info;

    try {
        info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(TAG, "bad menuinfo: ", e);
        return;
    }

    long packedPosition = info.packedPosition;
    boolean isChild = isChild(packedPosition);

    // get the entry name for the item
    String menuName;
    if (isChild) {
        getMenuInflater().inflate(R.menu.roster_item_contextmenu, menu);
        menuName = String.format("%s (%s)",
                                 getPackedItemRow(packedPosition, RosterConstants.ALIAS),
                                 getPackedItemRow(packedPosition, RosterConstants.JID));
    } else {
        menuName = getPackedItemRow(packedPosition, RosterConstants.GROUP);
        if (menuName.equals(""))
            return; // no options for default menu
        getMenuInflater().inflate(R.menu.roster_group_contextmenu, menu);
    }

    menu.setHeaderTitle(getString(R.string.roster_contextmenu_title, menuName));
}
项目:ZicroBrowser    文件:HistoryListActivity.java   
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuItem.getMenuInfo();

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

    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        int child = ExpandableListView.getPackedPositionChild(info.packedPosition);

        HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child);

        switch (menuItem.getItemId()) {
        case MENU_OPEN_IN_TAB:
            doNavigateToUrl(item.getUrl(), true);
            break;
        case MENU_COPY_URL:
            ApplicationUtils.copyTextToClipboard(this, item.getUrl(), getString(R.string.Commons_UrlCopyToastMessage));
            break;
        case MENU_SHARE:
            ApplicationUtils.sharePage(this, item.getTitle(), item.getUrl());
            break;
        case MENU_DELETE_FROM_HISTORY:
            BookmarksProviderWrapper.deleteHistoryRecord(getContentResolver(), item.getId());
            fillData();
            break;
        default:
            break;
        }
    }

    return super.onContextItemSelected(menuItem);
}
项目:codemap    文件:WorkspaceBrowser.java   
public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo) {
    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    int type = ExpandableListView
            .getPackedPositionType(info.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        new MenuInflater(getContext()).inflate(R.menu.workspace_browser, menu);
    }
}
项目:codemap    文件:WorkspaceBrowser.java   
public void handleLongClick(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item
            .getMenuInfo();

    Log.d("CodeMap", "handlelongclick!");
    int type = ExpandableListView
            .getPackedPositionType(info.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPosition = ExpandableListView
                .getPackedPositionGroup(info.packedPosition);
        String group = adapter.getGroup(groupPosition);
        Toast.makeText(getContext(), "Clicked! " + group, Toast.LENGTH_SHORT).show();
    }
}
项目:document-viewer    文件:OPDSActivity.java   
/**
 * {@inheritDoc}
 *
 * @see android.app.Activity#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)
 */
@Override
public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
    if (menuInfo instanceof ExpandableListContextMenuInfo) {
        final ExpandableListContextMenuInfo cmi = (ExpandableListContextMenuInfo) menuInfo;
        final int type = ExpandableListView.getPackedPositionType(cmi.packedPosition);
        final int groupPosition = ExpandableListView.getPackedPositionGroup(cmi.packedPosition);
        final int childPosition = ExpandableListView.getPackedPositionChild(cmi.packedPosition);
        // System.out.println("OPDSActivity.onCreateContextMenu(): " + type + ", " + groupPosition + ", "
        // + childPosition);
        switch (type) {
            case ExpandableListView.PACKED_POSITION_TYPE_NULL:
                onCreateContextMenu(menu);
                return;
            case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
                final Entry entry = getController().adapter.getGroup(groupPosition);
                if (entry instanceof Feed) {
                    onCreateFeedContextMenu(menu, (Feed) entry);
                } else if (entry instanceof Book) {
                    onCreateBookContextMenu(menu, (Book) entry);
                }
                return;
            case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
                final Entry group = getController().adapter.getGroup(groupPosition);
                final Object child = getController().adapter.getChild(groupPosition, childPosition);
                if (child instanceof Link) {
                    onCreateLinkContextMenu(menu, (Book) group, (Link) child);
                } else if (child instanceof Feed) {
                    onCreateFacetContextMenu(menu, (Feed) group, (Feed) child);
                }
                return;
        }
    }
    onCreateContextMenu(menu);
}
项目:ircradio    文件:ActChannelList.java   
public void populateList() {
  ExpandableListView listView = (ExpandableListView) findViewById(R.id.channelListView);
  adapter = new ExpandableListChannelAdapter(this);
  listView.setAdapter(adapter);

    listView.setOnChildClickListener(this);        
    listView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {

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

            ExpandableListContextMenuInfo elcm = (ExpandableListContextMenuInfo) menuInfo;

            int type = ExpandableListView.getPackedPositionType(elcm.packedPosition);
            if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {

                int groupPosition = ExpandableListView.getPackedPositionGroup(elcm.packedPosition);
                int childPosition = ExpandableListView.getPackedPositionChild(elcm.packedPosition);
                String channel = adapter.children[groupPosition][childPosition];


                menu.setHeaderTitle(channel);
                menu.add(0, 0, 0, R.string.ctx_clear);
                if (channel.startsWith("#")){
                  menu.add(0, 1, 0, R.string.ctx_part);
                }
                menu.add(0, 2, 0 , R.string.ctx_close);
                menu.add(0, 3, 0, R.string.ctx_activatespeech);   

            }else{

                menu.setHeaderTitle(adapter.groupNames[ExpandableListView.getPackedPositionGroup(elcm.packedPosition)]);                    
                menu.add(0, 0, 0, R.string.ctx_viewlog);                    
                menu.add(0, 1, 0, R.string.ctx_clear);
                menu.add(0, 2, 0, R.string.ctx_disconnect);
                menu.add(0, 3, 0, R.string.ctx_close);
                menu.add(0, 4, 0, R.string.ctx_activatespeech);                    
            }
        }

    });

}
项目:ircradio    文件:ActAccountList.java   
public void populateList() {


  ExpandableListView listView = (ExpandableListView) findViewById(R.id.accountListView);
    //ListView listView = new ListView(this);



    adapter = new ExpandableListORMAccountAdapter(this);
    adapter.setData(ExpandableListORMAccountAdapter.AdapterBundle.getAdapterBundle());

    listView.setAdapter(adapter);

    listView.setOnChildClickListener(this);
    listView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {

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

                    ExpandableListContextMenuInfo elcm = (ExpandableListContextMenuInfo) menuInfo;

                    int type = ExpandableListView.getPackedPositionType(elcm.packedPosition);
                    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {

                        int groupPosition = ExpandableListView.getPackedPositionGroup(elcm.packedPosition);
                        int childPosition = ExpandableListView.getPackedPositionChild(elcm.packedPosition);                         

                        menu.setHeaderTitle(R.string.ctx_title_channelmenu);
                        menu.add(0, 3, 0, R.string.ctx_viewmessages);
                        menu.add(0, 0, 1, R.string.ctx_part);                                                                                    
                        menu.add(0, 1, 2, R.string.ctx_edit);
                        menu.add(0, 2, 3, R.string.ctx_delete);                               
                    }

                    else {
                        menu.setHeaderTitle(R.string.ctx_title_servermenu);                 
                        menu.add(0, 0, 0, R.string.ctx_addchannel);
                        menu.add(0, 1, 0, R.string.ctx_connect);                    
                        menu.add(0, 2, 0, R.string.ctx_disconnect);
                        menu.add(0, 3, 0, R.string.ctx_edit);
                        menu.add(0, 4, 0, R.string.ctx_delete);                                                
                    }}
            });

}
项目:ActivityLauncher    文件:AllTasksListFragment.java   
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo)item.getMenuInfo();
    ExpandableListView list = (ExpandableListView) getView().findViewById(R.id.expandableListView1);

    switch(ExpandableListView.getPackedPositionType(info.packedPosition)) {
    case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
        MyActivityInfo activity = (MyActivityInfo) list.getExpandableListAdapter().getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition));
        switch(item.getItemId()) {
        case 0:
            LauncherIconCreator.createLauncherIcon(getActivity(), activity);
            break;
        case 1:
            LauncherIconCreator.launchActivity(getActivity(), activity.component_name);
            break;
        case 2:
            DialogFragment dialog = new ShortcutEditDialogFragment();
            Bundle args = new Bundle();
            args.putParcelable("activity", activity.component_name);
            dialog.setArguments(args);
            dialog.show(this.getFragmentManager(), "ShortcutEditor");
            break;
        }
        break;

    case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
        MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
        switch(item.getItemId()) {
        case 0:
            LauncherIconCreator.createLauncherIcon(getActivity(), pack);
            break;
        case 1:
            PackageManager pm = getActivity().getPackageManager();
            Intent intent = pm.getLaunchIntentForPackage(pack.package_name);
            Toast.makeText(getActivity(), String.format(getText(R.string.starting_application).toString(), pack.name), Toast.LENGTH_LONG).show();
            getActivity().startActivity(intent);
            break;
        }
    }
    return super.onContextItemSelected(item);
}
项目:VlcTest    文件:AudioAlbumsSongsFragment.java   
private boolean handleContextItemSelected(MenuItem item, int position) {
    ContextMenuInfo menuInfo = item.getMenuInfo();

    int startPosition;
    int groupPosition;
    List<String> medias;
    int id = item.getItemId();

    boolean useAllItems = id == R.id.audio_list_browser_play_all;
    boolean append = id == R.id.audio_list_browser_append;

    if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    }
    else
        groupPosition = position;

    if (id == R.id.audio_list_browser_delete) {
        AlertDialog alertDialog = CommonDialogs.deleteMedia(
                getActivity(),
                mSongsAdapter.getLocations(groupPosition).get(0),
                new VLCRunnable(mSongsAdapter.getItem(groupPosition)) {
                    @Override
                    public void run(Object o) {
                        AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem)o;
                        Media media = listItem.mMediaList.get(0);
                        mMediaLibrary.getMediaItems().remove(media);
                        mSongsAdapter.removeMedia(media);
                        mAlbumsAdapter.removeMedia(media);
                        mAudioController.removeLocation(media.getLocation());
                    }
                });
        alertDialog.show();
        return true;
    }

    if (id == R.id.audio_list_browser_set_song) {
        AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition).mMediaList.get(0), getActivity());
        return true;
    }

    if (useAllItems) {
        medias = new ArrayList<String>();
        startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
    }
    else {
        startPosition = 0;
        switch (mTabHost.getCurrentTab())
        {
            case 0: // albums
                medias = mAlbumsAdapter.getLocations(groupPosition);
                break;
            case 1: // songs
                medias = mSongsAdapter.getLocations(groupPosition);
                break;
            default:
                return true;
        }
    }

    if (append)
        mAudioController.append(medias);
    else
        mAudioController.load(medias, startPosition);

    return super.onContextItemSelected(item);
}
项目:VlcTest    文件:AudioBrowserFragment.java   
private boolean handleContextItemSelected(MenuItem item, int position) {
    ContextMenuInfo menuInfo = item.getMenuInfo();

    int startPosition;
    int groupPosition;
    List<String> medias;
    int id = item.getItemId();

    boolean useAllItems = id == R.id.audio_list_browser_play_all;
    boolean append = id == R.id.audio_list_browser_append;

    if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    }
    else
        groupPosition = position;

    if (id == R.id.audio_list_browser_delete) {
        AlertDialog alertDialog = CommonDialogs.deleteMedia(
                getActivity(),
                mSongsAdapter.getLocations(groupPosition).get(0),
                new VLCRunnable(mSongsAdapter.getItem(groupPosition)) {
                    @Override
                    public void run(Object o) {
                        AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem)o;
                        Media media = listItem.mMediaList.get(0);
                        mMediaLibrary.getMediaItems().remove(media);
                        mAudioController.removeLocation(media.getLocation());
                        updateLists();
                    }
                });
        alertDialog.show();
        return true;
    }

    if (id == R.id.audio_list_browser_set_song) {
        AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition).mMediaList.get(0), getActivity());
        return true;
    }

    if (useAllItems) {
        medias = new ArrayList<String>();
        startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
    }
    else {
        startPosition = 0;
        switch (mFlingViewGroup.getPosition())
        {
            case MODE_SONG:
                medias = mSongsAdapter.getLocations(groupPosition);
                break;
            case MODE_ARTIST:
                medias = mArtistsAdapter.getLocations(groupPosition);
                break;
            case MODE_ALBUM:
                medias = mAlbumsAdapter.getLocations(groupPosition);
                break;
            case MODE_GENRE:
                medias = mGenresAdapter.getLocations(groupPosition);
                break;
            default:
                return true;
        }
    }

    if (append)
        mAudioController.append(medias);
    else
        mAudioController.load(medias, startPosition);

    return super.onContextItemSelected(item);
}
项目:dv-quiz    文件:MainActivity.java   
@Override  
  public boolean onContextItemSelected(MenuItem item) { 

    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();

switch (ExpandableListView.getPackedPositionType(info.packedPosition))
{
case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
    Category selectedCategory = (Category) this.listAdapter.getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));

    switch (item.getItemId())
    {
    case CONTEXT_MENU_EDIT:
        dvQuizContext.getInstance().setValue("selectedCategory", selectedCategory);

        this.startActivityForResult(new Intent(this, CategoryFormActivity.class), dvQuizReference.ADD_NEW_CATEGORY.getReferenceValue());

        return true;
    case CONTEXT_MENU_DELETE:
        selectedCategory.delete();

        this.redrawListData();

        Toast.makeText(MainActivity.this, String.format(this.getString(R.string.info_object_successfully_delete), selectedCategory.toString()), Toast.LENGTH_SHORT).show();

        return true;
    }

    break;
case ExpandableListView.PACKED_POSITION_TYPE_CHILD:         
    Quiz selectedQuiz = (Quiz) this.listAdapter.getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition));

    switch (item.getItemId())
    {
    case CONTEXT_MENU_EDIT:
        dvQuizContext.getInstance().setValue("selectedQuiz", selectedQuiz);

        this.startActivity(new Intent(this, QuizFormActivity.class));
        return true;
    case CONTEXT_MENU_DELETE:
        selectedQuiz.delete();

        this.redrawListData();

        Toast.makeText(MainActivity.this, String.format(this.getString(R.string.info_object_successfully_delete), selectedQuiz.toString()), Toast.LENGTH_SHORT).show();

        return true;
    }
    break;
default:
    return false;
}

    return false;  
  }
项目:popcorntime-android-kitkat    文件:AudioAlbumsSongsFragment.java   
private boolean handleContextItemSelected(MenuItem item, int position) {
    ContextMenuInfo menuInfo = item.getMenuInfo();

    int startPosition;
    int groupPosition;
    List<String> medias;
    int id = item.getItemId();

    boolean useAllItems = id == R.id.audio_list_browser_play_all;
    boolean append = id == R.id.audio_list_browser_append;

    if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    }
    else
        groupPosition = position;

    if (id == R.id.audio_list_browser_delete) {
        AlertDialog alertDialog = CommonDialogs.deleteMedia(
                getActivity(),
                mSongsAdapter.getLocations(groupPosition).get(0),
                new VlcRunnable(mSongsAdapter.getItem(groupPosition)) {
                    @Override
                    public void run(Object o) {
                        Media aMedia = (Media) o;
                        mMediaLibrary.getMediaItems().remove(aMedia);
                        updateList();
                    }
                });
        alertDialog.show();
        return true;
    }

    if (id == R.id.audio_list_browser_set_song) {
        //AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition),getActivity());
        return true;
    }

    if (useAllItems) {
        medias = new ArrayList<String>();
        startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
    }
    else {
        startPosition = 0;
        switch (mTabHost.getCurrentTab())
        {
            case 0: // albums
                medias = mAlbumsAdapter.getLocations(groupPosition);
                break;
            case 1: // songs
                medias = mSongsAdapter.getLocations(groupPosition);
                break;
            default:
                return true;
        }
    }

    if (append)
        mAudioController.append(medias);
    else
        mAudioController.load(medias, startPosition);

    return super.onContextItemSelected(item);
}
项目:popcorntime-android-kitkat    文件:AudioBrowserFragment.java   
private boolean handleContextItemSelected(MenuItem item, int position) {
    ContextMenuInfo menuInfo = item.getMenuInfo();

    int startPosition;
    int groupPosition;
    List<String> medias;
    int id = item.getItemId();

    boolean useAllItems = id == R.id.audio_list_browser_play_all;
    boolean append = id == R.id.audio_list_browser_append;

    if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    }
    else
        groupPosition = position;

    if (id == R.id.audio_list_browser_delete) {
        AlertDialog alertDialog = CommonDialogs.deleteMedia(
                getActivity(),
                mSongsAdapter.getLocations(groupPosition).get(0),
                new VlcRunnable(mSongsAdapter.getItem(groupPosition)) {
                    @Override
                    public void run(Object o) {
                        Media aMedia = (Media) o;
                        mMediaLibrary.getMediaItems().remove(aMedia);
                        updateLists();
                    }
                });
        alertDialog.show();
        return true;
    }

    if (id == R.id.audio_list_browser_set_song) {
        //AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition),getActivity());
        return true;
    }

    if (useAllItems) {
        medias = new ArrayList<String>();
        startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
    }
    else {
        startPosition = 0;
        switch (mFlingViewGroup.getPosition())
        {
            case MODE_SONG:
                medias = mSongsAdapter.getLocations(groupPosition);
                break;
            case MODE_ARTIST:
                medias = mArtistsAdapter.getLocations(groupPosition);
                break;
            case MODE_ALBUM:
                medias = mArtistsAdapter.getLocations(groupPosition);
                break;
            case MODE_GENRE:
                medias = mGenresAdapter.getLocations(groupPosition);
                break;
            default:
                return true;
        }
    }

    if (append)
        mAudioController.append(medias);
    else
        mAudioController.load(medias, startPosition);

    return super.onContextItemSelected(item);
}
项目:Android-Application-Using-CAF-Library    文件:ArtistAlbumBrowserActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this, sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);

    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;

    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
        mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mCurrentAlbumId = null;
        mIsUnknownArtist = mCurrentArtistName == null ||
                mCurrentArtistName.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = true;
        if (mIsUnknownArtist) {
            menu.setHeaderTitle(getString(R.string.unknown_artist_name));
        } else {
            menu.setHeaderTitle(mCurrentArtistName);
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
        return;
    } else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        if (cpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no child");
            return;
        }
        Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
        c.moveToPosition(cpos);
        mCurrentArtistId = null;
        mCurrentAlbumId = Long.valueOf(mi.id).toString();
        mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistNameForAlbum = mArtistCursor.getString(
                mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mIsUnknownArtist = mCurrentArtistNameForAlbum == null ||
                mCurrentArtistNameForAlbum.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = mCurrentAlbumName == null ||
                mCurrentAlbumName.equals(MediaStore.UNKNOWN_STRING);
        if (mIsUnknownAlbum) {
            menu.setHeaderTitle(getString(R.string.unknown_album_name));
        } else {
            menu.setHeaderTitle(mCurrentAlbumName);
        }
        if (!mIsUnknownAlbum || !mIsUnknownArtist) {
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
    }
}