List of usage examples for android.widget ExpandableListView getPackedPositionChild
public static int getPackedPositionChild(long packedPosition)
From source file:org.tigase.mobile.bookmarks.BookmarksActivity.java
@TargetApi(11) private void initializeContextActions() { listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { private Bookmark getBookmarkFromFlatPosition(int pos) { long packed = listView.getExpandableListPosition(pos); int child = ExpandableListView.getPackedPositionChild(packed); int group = ExpandableListView.getPackedPositionGroup(packed); return (Bookmark) adapter.getChild(group, child); }/*www .j ava 2 s.c o m*/ @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { SparseBooleanArray selection = listView.getCheckedItemPositions(); if (item.getItemId() == R.id.edit) { for (int i = 0; i < selection.size(); i++) { if (selection.valueAt(i)) { int pos = selection.keyAt(i); Bookmark bookmark = getBookmarkFromFlatPosition(pos); editItem(bookmark); } } mode.finish(); // Action picked, so close the CAB return true; } else if (item.getItemId() == R.id.remove) { List<Bookmark> items = new ArrayList<Bookmark>(); for (int i = 0; i < selection.size(); i++) { if (selection.valueAt(i)) { int pos = selection.keyAt(i); Bookmark bookmark = getBookmarkFromFlatPosition(pos); if (bookmark != null) { items.add(bookmark); } } } removeItems(items); mode.finish(); return true; } else { return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.bookmarks_context_menu, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { // TODO Auto-generated method stub } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { Menu menu = mode.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem mi = menu.getItem(i); if (mi.getItemId() == R.id.edit) { mi.setVisible(listView.getCheckedItemCount() < 2); } } } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { // TODO Auto-generated method stub return true; } }); }
From source file:edu.chalmers.dat255.audiobookplayer.view.BookshelfFragment.java
@SuppressWarnings("rawtypes") @Override//from w ww . j ava 2 s . c o m public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // check that the menuInfo is of the correct type // this method is allowed to have quite a high cyclomatic complexity as // it would otherwise cause code duplication if (menuInfo instanceof ExpandableListContextMenuInfo && adapter != null) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo; // get the provided book position int bookIndex = ExpandableListView.getPackedPositionGroup(info.packedPosition); // trackIndex will be -1 if group is clicked int trackIndex = ExpandableListView.getPackedPositionChild(info.packedPosition); // get the type of the context menu int type = ExpandableListView.getPackedPositionType(info.packedPosition); // create an empty array to prevent trying to loop over an // uninitialized variable IContextMenuItem[] menuItems = new IContextMenuItem[0]; String title = ""; // fill the context menu with the correct items if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { // get all menu items from the child context menu menuItems = ChildContextMenuItem.values(); // set the context menu's title to that of the value of the // child title = adapter.getChild(bookIndex, trackIndex); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { // get all menu items from the group context menu menuItems = GroupContextMenuItem.values(); // set the context menu's title to that of the value of the book title = adapter.getGroup(bookIndex); } // set the title menu.setHeaderTitle(title); // populate the context menu with items in the order they were // declared in the enum declaration. for (IContextMenuItem item : menuItems) { // as this only loops when menuItems is of either of type // GroupContextMenuItem[] or ChildContextMenuItem[], Enum can be // used as a raw type menu.add(Menu.NONE, ((Enum) item).ordinal(), ((Enum) item).ordinal(), item.getText()); } } }
From source file:com.login.home.java
@Override public boolean onContextItemSelected(MenuItem item) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo(); int type = ExpandableListView.getPackedPositionType(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition); @SuppressWarnings("unchecked") HashMap<String, String> o = (HashMap<String, String>) mAdapter.getChild(groupPos, childPos); SharedPreferences settings = getSharedPreferences("pref_meetmethere", 0); ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); String log = settings.getString("login", "error"); String pass = settings.getString("password", "error"); postParameters.add(new BasicNameValuePair("login", log)); postParameters.add(new BasicNameValuePair("password", pass)); postParameters.add(new BasicNameValuePair("id", o.get("id"))); if (groupPos == 1 || groupPos == 0) { switch (item.getItemId()) { case 0: postParameters.add(new BasicNameValuePair("confirmed", "1")); break; case 1: postParameters.add(new BasicNameValuePair("confirmed", "2")); break; case 2: if (groupPos == 0) { Intent intent = new Intent(home.this, event_info.class); intent.putExtra("longitude", o.get("longitude")); intent.putExtra("latitude", o.get("latitude")); intent.putExtra("willAttend", o.get("willAttend")); intent.putExtra("address", o.get("address")); intent.putExtra("id", o.get("id")); intent.putExtra("title", o.get("title")); intent.putExtra("startdate", o.get("startdate")); intent.putExtra("enddate", o.get("enddate")); intent.putExtra("address", o.get("address")); intent.putExtra("description", o.get("description")); startActivity(intent); } else if (groupPos == 1) { String friend = o.get("login"); Intent intent = new Intent(home.this, profile.class); intent.putExtra("friend", friend); intent.putExtra("yourrequest", "true"); intent.putExtra("id", o.get("id")); intent.putExtra("confirmed", "0"); startActivity(intent); }/*from www . j av a 2 s . c om*/ break; } String response = null; try { if (groupPos == 1) response = CustomHttpClient.executeHttpPost( "http://antoines.goldzoneweb.info/accept_contact.php", postParameters); else response = CustomHttpClient.executeHttpPost( "http://antoines.goldzoneweb.info/accept_event.php", postParameters); String res = response.toString(); res = res.replaceAll("\\s+", ""); if (res.equals("OK")) { Intent myIntent = new Intent(home.this, home.class); startActivityForResult(myIntent, 0); } } catch (Exception e) { System.out.println("Error occured"); } } else if (groupPos == 2) { switch (item.getItemId()) { case 0: Intent intent = new Intent(home.this, event_info.class); intent.putExtra("longitude", o.get("longitude")); intent.putExtra("latitude", o.get("latitude")); intent.putExtra("willAttend", o.get("willAttend")); intent.putExtra("address", o.get("address")); intent.putExtra("id", o.get("id")); intent.putExtra("title", o.get("title")); intent.putExtra("startdate", o.get("startdate")); intent.putExtra("enddate", o.get("enddate")); intent.putExtra("address", o.get("address")); intent.putExtra("description", o.get("description")); startActivity(intent); break; case 1: Intent intent2 = new Intent(home.this, mapevent.class); intent2.putExtra("longitude", o.get("longitude")); intent2.putExtra("latitude", o.get("latitude")); intent2.putExtra("willAttend", o.get("willAttend")); intent2.putExtra("address", o.get("address")); intent2.putExtra("id", o.get("id")); intent2.putExtra("title", o.get("title")); intent2.putExtra("startdate", o.get("startdate")); intent2.putExtra("enddate", o.get("enddate")); intent2.putExtra("address", o.get("address")); intent2.putExtra("description", o.get("description")); startActivity(intent2); break; case 2: postParameters.add(new BasicNameValuePair("confirmed", "2")); String response = null; try { response = CustomHttpClient.executeHttpPost( "http://antoines.goldzoneweb.info/accept_event.php", postParameters); String res = response.toString(); res = res.replaceAll("\\s+", ""); if (res.equals("OK")) { Intent myIntent = new Intent(home.this, home.class); startActivityForResult(myIntent, 0); } } catch (Exception e) { System.out.println("Error occured"); } break; } } } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { return true; } return false; }
From source file:com.money.manager.ex.common.CategoryListFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) item .getMenuInfo();/*from ww w. j av a2 s . c o m*/ int type = ExpandableListView.getPackedPositionType(info.packedPosition); int group = ExpandableListView.getPackedPositionGroup(info.packedPosition); int child = ExpandableListView.getPackedPositionChild(info.packedPosition); CategorySub categoryIds = new CategorySub(); categoryIds.categId = Constants.NOT_SET; categoryIds.categName = ""; categoryIds.subCategId = Constants.NOT_SET; categoryIds.subCategName = ""; if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { categoryIds.categId = mCategories.get(group).getId(); categoryIds.categName = mCategories.get(group).getName(); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { categoryIds.categId = mSubCategories.get(mCategories.get(group)).get(child).getCategId(); categoryIds.subCategId = mSubCategories.get(mCategories.get(group)).get(child).getSubCategId(); categoryIds.subCategName = mSubCategories.get(mCategories.get(group)).get(child).getSubcategoryName() .toString(); } // manage select menu ContextMenuIds menuId = ContextMenuIds.get(item.getItemId()); switch (menuId) { case EDIT: if (categoryIds.subCategId == ExpandableListView.INVALID_POSITION) { showDialogEditCategoryName(SQLTypeTransaction.UPDATE, categoryIds.categId, categoryIds.categName); } else { showDialogEditSubCategoryName(SQLTypeTransaction.UPDATE, categoryIds.categId, categoryIds.subCategId, categoryIds.subCategName); } break; case DELETE: showDialogDeleteCategorySub(categoryIds); break; case VIEW_TRANSACTIONS: // view transactions SearchParameters parameters = new SearchParameters(); parameters.category = categoryIds; showSearchActivityFor(parameters); } return false; }
From source file:org.jitsi.android.gui.contactlist.ContactListFragment.java
/** * {@inheritDoc}/*w w w . ja v a2 s . c om*/ */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (contactListView.getExpandableListAdapter() != getContactListAdapter()) { return; } ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int type = ExpandableListView.getPackedPositionType(info.packedPosition); int group = ExpandableListView.getPackedPositionGroup(info.packedPosition); int child = ExpandableListView.getPackedPositionChild(info.packedPosition); // Only create a context menu for child items MenuInflater inflater = getActivity().getMenuInflater(); if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { createGroupCtxMenu(menu, inflater, group); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { createContactCtxMenu(menu, inflater, group, child); } }
From source file:edu.chalmers.dat255.audiobookplayer.view.BookshelfFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { if (getActivity() == null) { return false; }//from w ww . ja v a2 s . c o m // this method is allowed to have quite a high cyclomatic complexity as // it would otherwise cause code duplication ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo(); // get the provided book position int bookIndex = ExpandableListView.getPackedPositionGroup(info.packedPosition); // will be -1 if the type is group int trackIndex = ExpandableListView.getPackedPositionChild(info.packedPosition); // get the type of the context menu int type = ExpandableListView.getPackedPositionType(info.packedPosition); // create an empty array to prevent trying to loop over an uninitialized // variable IContextMenuItem[] menuItems = new IContextMenuItem[0]; // fill the array with the correct items if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { menuItems = ChildContextMenuItem.values(); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { menuItems = GroupContextMenuItem.values(); } // get an item and store it with its dynamic type IContextMenuItem menuItem = menuItems[item.getItemId()]; // if the type of the context menu is group if (menuItem instanceof GroupContextMenuItem) { // perform the correct task executeGroupMenuItem((GroupContextMenuItem) menuItem, bookIndex); } // if the type of the context menu is that of a child else if (menuItem instanceof ChildContextMenuItem) { // perform the correct task executeChildMenuItem((ChildContextMenuItem) menuItem, bookIndex, trackIndex); } return true; }
From source file:co.nerdart.ourss.fragment.FeedsListFragment.java
private void moveItem(boolean fromIsGroup, boolean toIsGroup, boolean fromIsFeedWithoutGroup, long packedPosTo, int packedGroupPosTo, int flatPosFrom) { ContentValues values = new ContentValues(); ContentResolver cr = getActivity().getContentResolver(); if (fromIsGroup && toIsGroup) { values.put(FeedColumns.PRIORITY, packedGroupPosTo + 1); cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null); cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null); } else if (!fromIsGroup && toIsGroup) { values.put(FeedColumns.PRIORITY, packedGroupPosTo + 1); values.putNull(FeedColumns.GROUP_ID); cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null); cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null); } else if ((!fromIsGroup && !toIsGroup) || (fromIsFeedWithoutGroup && !toIsGroup)) { int groupPrio = ExpandableListView.getPackedPositionChild(packedPosTo) + 1; values.put(FeedColumns.PRIORITY, groupPrio); int flatGroupPosTo = mListView .getFlatListPosition(ExpandableListView.getPackedPositionForGroup(packedGroupPosTo)); values.put(FeedColumns.GROUP_ID, mListView.getItemIdAtPosition(flatGroupPosTo)); cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null); cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null); }/*from w ww . j a va2s . c om*/ }
From source file:org.videolan.vlc.gui.audio.AudioBrowserFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { if (!getUserVisibleHint()) return super.onContextItemSelected(item); ContextMenuInfo menuInfo = item.getMenuInfo(); if (menuInfo == null) return super.onContextItemSelected(item); int startPosition; int groupPosition; int childPosition; List<String> medias; int id = item.getItemId(); boolean useAllItems = (id == R.id.audio_list_browser_play_all || id == R.id.audio_list_browser_append_all); boolean append = (id == R.id.audio_list_browser_append || id == R.id.audio_list_browser_append_all); if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo; groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition); childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition); if (childPosition < 0) childPosition = 0;// ww w. ja v a2 s .c om } else { AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; groupPosition = info.position; childPosition = 0; } if (id == R.id.audio_list_browser_delete) { AlertDialog alertDialog = CommonDialogs.deleteMedia(getActivity(), mSongsAdapter.getLocation(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) { startPosition = groupPosition; medias = mSongsAdapter.getLocations(); } else { startPosition = 0; switch (mFlingViewGroup.getPosition()) { case MODE_SONG: medias = mSongsAdapter.getLocation(groupPosition); break; case MODE_ARTIST: medias = mArtistsAdapter.getPlaylist(groupPosition, childPosition); break; case MODE_ALBUM: medias = mAlbumsAdapter.getPlaylist(groupPosition, childPosition); break; case MODE_GENRE: medias = mGenresAdapter.getPlaylist(groupPosition, childPosition); break; default: return true; } } if (append) mAudioController.append(medias); else mAudioController.load(medias, startPosition); AudioPlayerActivity.start(getActivity()); return super.onContextItemSelected(item); }
From source file:the.joevlc.AudioBrowserFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { ContextMenuInfo menuInfo = item.getMenuInfo(); if (menuInfo == null) return super.onContextItemSelected(item); int startPosition; int groupPosition; int childPosition; List<String> medias; int id = item.getItemId(); boolean useAllItems = (id == R.id.audio_list_browser_play_all || id == R.id.audio_list_browser_append_all); boolean append = (id == R.id.audio_list_browser_append || id == R.id.audio_list_browser_append_all); if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo; groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition); childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition); if (childPosition < 0) childPosition = 0;/* www . ja v a2 s. com*/ } else { AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; groupPosition = info.position; childPosition = 0; } if (id == R.id.audio_list_browser_delete) { AlertDialog alertDialog = CommonDialogs.deleteMedia(getActivity(), mSongsAdapter.getLocation(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) { startPosition = groupPosition; medias = mSongsAdapter.getLocations(); } else { startPosition = 0; switch (mFlingViewGroup.getPosition()) { case MODE_SONG: medias = mSongsAdapter.getLocation(groupPosition); break; case MODE_ARTIST: medias = mArtistsAdapter.getPlaylist(groupPosition, childPosition); break; case MODE_ALBUM: medias = mAlbumsAdapter.getPlaylist(groupPosition, childPosition); break; case MODE_GENRE: medias = mGenresAdapter.getPlaylist(groupPosition, childPosition); break; default: return true; } } if (append) mAudioController.append(medias); else mAudioController.load(medias, startPosition); AudioPlayerActivity.start(getActivity()); return super.onContextItemSelected(item); }
From source file:com.iskrembilen.quasseldroid.gui.fragments.BufferFragment.java
private void initActionMenu() { actionModeData.actionModeCallbackNetwork = new ActionMode.Callback() { @Override/*from w w w . j ava 2s . c o m*/ public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.buffer_contextual_menu_networks, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.context_menu_connect: BufferHelper.connectNetwork(actionModeData.id); mode.finish(); return true; case R.id.context_menu_disconnect: BufferHelper.disconnectNetwork(actionModeData.id); mode.finish(); return true; default: return false; } } @Override public void onDestroyActionMode(ActionMode mode) { // actionModeData.listItem.setActivated(false); actionModeData.actionMode = null; } }; actionModeData.actionModeCallbackBuffer = new ActionMode.Callback() { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.buffer_contextual_menu_channels, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; // Return false if nothing is done } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.context_menu_join: BufferHelper.joinChannel(actionModeData.id, bufferListAdapter.networks); mode.finish(); return true; case R.id.context_menu_part: BufferHelper.partChannel(actionModeData.id, bufferListAdapter.networks); mode.finish(); return true; case R.id.context_menu_delete: BufferHelper.showDeleteConfirmDialog(getSherlockActivity(), actionModeData.id); mode.finish(); return true; case R.id.context_menu_hide_temp: BufferHelper.tempHideChannel(actionModeData.id); mode.finish(); return true; case R.id.context_menu_hide_perm: BufferHelper.permHideChannel(actionModeData.id); mode.finish(); return true; default: return false; } } // Called when the user exits the action mode @Override public void onDestroyActionMode(ActionMode mode) { // actionModeData.listItem.setActivated(false); actionModeData.actionMode = null; } }; bufferList.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { long packedPosition = bufferList.getExpandableListPosition(position); int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition); int childPosition = ExpandableListView.getPackedPositionChild(packedPosition); if (ExpandableListView .getPackedPositionType(packedPosition) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { Buffer buffer = bufferListAdapter.getChild(groupPosition, childPosition); actionModeData.actionMode = getSherlockActivity() .startActionMode(actionModeData.actionModeCallbackBuffer); actionModeData.id = buffer.getInfo().id; actionModeData.listItem = view; if (buffer.getInfo().type == BufferInfo.Type.QueryBuffer) { actionModeData.actionMode.getMenu().findItem(R.id.context_menu_part).setVisible(false); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_delete).setVisible(true); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_join).setVisible(false); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_hide_temp).setVisible(true); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_hide_perm).setVisible(true); } else if (buffer.isActive()) { actionModeData.actionMode.getMenu().findItem(R.id.context_menu_part).setVisible(true); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_join).setVisible(false); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_delete).setVisible(false); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_hide_temp).setVisible(true); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_hide_perm).setVisible(true); } else { actionModeData.actionMode.getMenu().findItem(R.id.context_menu_part).setVisible(false); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_delete).setVisible(true); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_join).setVisible(true); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_hide_temp).setVisible(true); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_hide_perm).setVisible(true); } } else if (ExpandableListView .getPackedPositionType(packedPosition) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { Network network = bufferListAdapter.getGroup(groupPosition); actionModeData.actionMode = getSherlockActivity() .startActionMode(actionModeData.actionModeCallbackNetwork); actionModeData.id = network.getId(); actionModeData.listItem = view; if (network.isConnected()) { actionModeData.actionMode.getMenu().findItem(R.id.context_menu_disconnect).setVisible(true); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_connect).setVisible(false); } else { actionModeData.actionMode.getMenu().findItem(R.id.context_menu_disconnect) .setVisible(false); actionModeData.actionMode.getMenu().findItem(R.id.context_menu_connect).setVisible(true); } } return true; } }); }