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,R.string.HistoryListActivity_MenuOpenInTab);
        menu.add(0,MENU_copY_URL,R.string.BookmarksHistoryActivity_MenucopyLinkUrl);
        menu.add(0,MENU_SHARE,R.string.Main_MenuShareLinkUrl);
        menu.add(0,MENU_DELETE_FROM_HISTORY,R.string.HistoryListActivity_MenuDelete);
    }
}
项目:zirco-browser    文件HistoryListActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu,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,R.string.HistoryListActivity_MenuDelete);
    }
}
项目:ActivityLauncher    文件AllTasksListFragment.java   
@Override
public void onCreateContextMenu(ContextMenu menu,ContextMenuInfo menuInfo) {
    menu.add(Menu.NONE,Menu.NONE,R.string.context_action_shortcut);
    menu.add(Menu.NONE,1,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,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,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,R.string.HistoryListActivity_MenuDelete);
    }
}
项目:dv-quiz    文件MainActivity.java   
@Override  
  public void onCreateContextMenu(ContextMenu menu,ContextMenuInfo menuInfo) {

    super.onCreateContextMenu(menu,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,this.getString(R.string.edit));  
    menu.add(0,CONTEXT_MENU_DELETE,this.getString(R.string.delete));  
  }
项目:Zicrobrowser    文件HistoryListActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu,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,item.getId());
            fillData();
            break;
        default:
            break;
        }
    }

    return super.onContextItemSelected(menuItem);
}
项目:timetracker    文件ListRecordingsFragment.java   
@Override
public void onCreateContextMenu(ContextMenu menu,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,item.getId());
            fillData();
            break;
        default:
            break;
        }
    }

    return super.onContextItemSelected(menuItem);
}
项目:maven-yaxim    文件MainWindow.java   
@Override
public void onCreateContextMenu(ContextMenu menu,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),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,item.getId());
            fillData();
            break;
        default:
            break;
        }
    }

    return super.onContextItemSelected(menuItem);
}
项目:codemap    文件Workspacebrowser.java   
public void onCreateContextMenu(ContextMenu menu,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,(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,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,R.string.ctx_clear);
                if (channel.startsWith("#")){
                  menu.add(0,R.string.ctx_part);
                }
                menu.add(0,R.string.ctx_close);
                menu.add(0,3,R.string.ctx_activatespeech);   

            }else{

                menu.setHeaderTitle(adapter.groupNames[ExpandableListView.getPackedPositionGroup(elcm.packedPosition)]);                    
                menu.add(0,R.string.ctx_viewlog);                    
                menu.add(0,R.string.ctx_clear);
                menu.add(0,R.string.ctx_disconnect);
                menu.add(0,4,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,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,R.string.ctx_viewmessages);
                        menu.add(0,R.string.ctx_part);                                                                                    
                        menu.add(0,R.string.ctx_edit);
                        menu.add(0,R.string.ctx_delete);                               
                    }

                    else {
                        menu.setHeaderTitle(R.string.ctx_title_servermenu);                 
                        menu.add(0,R.string.ctx_addchannel);
                        menu.add(0,R.string.ctx_connect);                    
                        menu.add(0,R.string.ctx_disconnect);
                        menu.add(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,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),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,selectedQuiz.toString()),Toast.LENGTH_SHORT).show();

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

    return false;  
  }
项目:popcorntime-android-kitkat    文件AudioAlbumsSongsFragment.java   
private boolean handleContextItemSelected(MenuItem item,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),startPosition);

    return super.onContextItemSelected(item);
}
项目:popcorntime-android-kitkat    文件AudiobrowserFragment.java   
private boolean handleContextItemSelected(MenuItem item,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),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,R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0,ADD_TO_PLAYLIST,R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this,sub);
    menu.add(0,DELETE_ITEM,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,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,R.string.search_title);
        }
    }
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...