List of usage examples for android.view Menu removeGroup
public void removeGroup(int groupId);
From source file:fr.shywim.antoinedaniel.ui.fragment.GamesFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.removeGroup(R.id.sound_menu); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.janela.mobile.ui.user.HomeActivity.java
@Override public void onLoadFinished(Loader<List<User>> listLoader, List<User> orgs) { this.orgs = orgs; int sharedPreferencesOrgId = sharedPreferences.getInt(PREF_ORG_ID, -1); int targetOrgId = org == null ? sharedPreferencesOrgId : org.getId(); Menu menu = navigationView.getMenu(); menu.removeGroup(R.id.user_select); for (int i = 0; i < orgs.size(); ++i) { final MenuItem item = menu.add(R.id.user_select, i, Menu.NONE, orgs.get(i).getLogin()); avatars.bind(item, orgs.get(i)); if (orgs.get(i).getId() == targetOrgId) { setOrg(orgs.get(i));/*from w ww. j a v a2 s. c o m*/ } } // If the target org is invalid (e.g. first login), select the first one if (targetOrgId == -1 && orgs.size() > 0) { setOrg(orgs.get(0)); } menu.setGroupVisible(R.id.user_select, false); }
From source file:com.glabs.homegenie.fragments.GroupsViewFragment.java
public void UpdateJumpToGroupMenu(ArrayList<Group> groups) { StartActivity rootactivity = (StartActivity) getActivity(); if (rootactivity != null) { Menu menu = rootactivity.getActionMenu(); if (menu != null) { MenuItem jumpto = menu.findItem(R.id.action_jumpto); Menu submenu = jumpto.getSubMenu(); if (submenu == null) return; ////from ww w. jav a2 s . c om submenu.removeGroup(Menu.NONE); if (groups.size() > 0) { int gid = 0; for (Group group : groups) { MenuItem grp = submenu.add(Menu.NONE, gid, gid, group.Name); // prg.setIcon(R.drawable.ic_action_flash_on); MenuCompat.setShowAsAction(grp, SHOW_AS_ACTION_IF_ROOM | SHOW_AS_ACTION_WITH_TEXT); grp.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { mIndicator.setCurrentItem(menuItem.getItemId()); return true; } }); gid++; } } } } }
From source file:me.fattycat.kun.teamwork.ui.activity.MainActivity.java
private void initTeamProjectMenu(boolean isClear) { LogUtils.i(TAG, "initTeamProjectMenu"); Menu menu = mNavView.getMenu(); menu.removeGroup(233); SubMenu projectMenu = menu.addSubMenu(233, Menu.NONE, Menu.NONE, String.format("%s %s", getString(R.string.text_menu_project), TWSettings.sTeamList.get(TWSettings.sSelectedTeamPos).getName())); if (isClear) { projectMenu.add(Menu.NONE, Menu.NONE, Menu.NONE, " ...").setCheckable(true) .setIcon(android.R.color.transparent); return;//from w w w. j a v a2s . c o m } int index = 0; for (TeamProjectModel model : mTeamProjectList) { projectMenu.add(Menu.NONE, index++, Menu.NONE, model.getName()).setCheckable(true) .setIcon(android.R.color.transparent); } if (index == 0) { projectMenu.add(Menu.NONE, Menu.NONE, Menu.NONE, "").setCheckable(true) .setIcon(android.R.color.transparent); } }
From source file:com.glabs.homegenie.fragments.GroupsViewFragment.java
public void UpdateCurrentGroupMenu() { StartActivity rootactivity = (StartActivity) getActivity(); Menu menu = rootactivity.getActionMenu(); if (menu != null) { MenuItem automation = menu.findItem(R.id.menu_automation); if (automation != null) { automation.setEnabled(false); Menu submenu = automation.getSubMenu(); if (submenu == null) return; ////from ww w . j a v a 2s . c om submenu.removeGroup(Menu.NONE); if (mGroupPrograms.size() > 0) { for (Module program : mGroupPrograms) { MenuItem prg = submenu.add(Menu.NONE, Menu.NONE, Menu.NONE, program.getDisplayName()); prg.setIcon(R.drawable.ic_action_flash_on); MenuCompat.setShowAsAction(prg, SHOW_AS_ACTION_IF_ROOM | SHOW_AS_ACTION_WITH_TEXT); final String paddress = program.Address; String groupname = ""; try { groupname = Uri.encode(mAdapter.getGroup(mCurrentGroup).Name, "UTF-8"); } catch (Exception e) { } final String gname = groupname; prg.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { String apicall = "HomeAutomation.HomeGenie/Automation/Programs.Run/" + paddress + "/" + gname + "/" + new Date().getTime(); Control.callServiceApi(apicall, null); return true; } }); } automation.setEnabled(true); } } // // MenuItem recordMacro = submenu.add(1, Menu.NONE, Menu.NONE, "Record macro"); // recordMacro.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { // @Override // public boolean onMenuItemClick(MenuItem menuItem) { // StartActivity sa = (StartActivity)getActivity(); // sa.openMacroRecordMenu(); // return true; // } // }); // rootactivity.supportInvalidateOptionsMenu(); } }
From source file:org.intermine.app.activity.MainActivity.java
private void setMainMenuDisplayed(boolean displayed) { Menu menu = mNavigationView.getMenu(); menu.setGroupVisible(R.id.main, !displayed); menu.setGroupVisible(R.id.rest, !displayed); if (displayed) { menu.removeGroup(R.id.mines); Set<String> mines = getStorage().getSelectedMineNames(); int counter = 0; for (String mine : mines) { menu.add(R.id.mines, counter, counter, mine); counter++;//from w w w. ja v a2s. co m } } menu.setGroupVisible(R.id.mines, displayed); }
From source file:fr.shywim.antoinedaniel.ui.fragment.SoundPagerFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.removeGroup(R.id.sound_menu); inflater.inflate(R.menu.sound_options_menu, menu); // find the searchView and handle search manually inside fragment MenuItem searchItem = menu.findItem(R.id.search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (searchView != null) { searchView.setOnQueryTextListener(this); MainActivity act = (MainActivity) getActivity(); if (act.searchQuery != null) { searchItem.expandActionView(); ((EditText) searchView.findViewById(R.id.search_src_text)).setText(act.searchQuery); switchFragmentsIfNecessary(true, act.searchQuery); }// w w w.j ava 2 s .c om } super.onCreateOptionsMenu(menu, inflater); }
From source file:com.stoyanr.feeder.activity.ChannelsActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); Cursor cursor = adapter.getCursor(); if (cursor == null || cursor.getCount() == 0) { menu.removeGroup(R.id.group_channels); }/* ww w. ja va2 s . co m*/ return true; }
From source file:org.mariotaku.twidere.fragment.UserListFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { final ParcelableUserList userList = mUserList; MenuUtils.setMenuItemAvailability(menu, R.id.info, userList != null); menu.removeGroup(MENU_GROUP_USER_LIST_EXTENSION); if (userList != null) { final boolean isMyList = userList.user_key.equals(userList.account_key); final boolean isFollowing = userList.is_following; MenuUtils.setMenuItemAvailability(menu, R.id.edit, isMyList); MenuUtils.setMenuItemAvailability(menu, R.id.follow, !isMyList); MenuUtils.setMenuItemAvailability(menu, R.id.add, isMyList); MenuUtils.setMenuItemAvailability(menu, R.id.delete, isMyList); final MenuItem followItem = menu.findItem(R.id.follow); if (isFollowing) { followItem.setIcon(R.drawable.ic_action_cancel); followItem.setTitle(R.string.unsubscribe); } else {/*from w ww . j a v a 2 s . c o m*/ followItem.setIcon(R.drawable.ic_action_add); followItem.setTitle(R.string.subscribe); } final Intent extensionsIntent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST); extensionsIntent.setExtrasClassLoader(getActivity().getClassLoader()); extensionsIntent.putExtra(EXTRA_USER_LIST, userList); MenuUtils.addIntentToMenu(getActivity(), menu, extensionsIntent, MENU_GROUP_USER_LIST_EXTENSION); } else { MenuUtils.setMenuItemAvailability(menu, R.id.edit, false); MenuUtils.setMenuItemAvailability(menu, R.id.follow, false); MenuUtils.setMenuItemAvailability(menu, R.id.add, false); MenuUtils.setMenuItemAvailability(menu, R.id.delete, false); } }
From source file:com.googlecode.android_scripting.facade.ui.UiFacade.java
public boolean onPrepareOptionsMenu(Menu menu) { if (mMenuUpdated.getAndSet(false)) { menu.removeGroup(MENU_GROUP_ID); for (UiMenuItem item : mOptionsMenuItems) { MenuItem menuItem = menu.add(MENU_GROUP_ID, Menu.NONE, Menu.NONE, item.mmTitle); if (item.mmIcon != null) { menuItem.setIcon(mService.getResources().getIdentifier(item.mmIcon, "drawable", "android")); }/*from w w w .j av a 2 s . com*/ menuItem.setOnMenuItemClickListener(item.mmListener); } return true; } return true; }