List of usage examples for android.view Menu size
public int size();
From source file:com.irccloud.android.activity.BaseActivity.java
public void setMenuColorFilter(final Menu menu) { for (int i = 0; i < menu.size(); i++) { MenuItem menuItem = menu.getItem(i); Drawable d = menuItem.getIcon(); if (d != null) { d.mutate();/* ww w.j a v a 2 s . c o m*/ d.setColorFilter(ColorScheme.getInstance().navBarSubheadingColor, PorterDuff.Mode.SRC_ATOP); } } }
From source file:net.zorgblub.typhon.fragment.CatalogFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { Option<Feed> feed = adapter.getFeed(); boolean searchEnabled = !isEmpty(feed.flatMap(Feed::getSearchLink)); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); boolean enabled; switch (item.getItemId()) { case R.id.search: enabled = searchEnabled;/* w ww. j a v a 2s.c om*/ break; default: enabled = true; } item.setEnabled(enabled); item.setVisible(enabled); } LOG.debug("Adapter has feed: " + adapter.getFeed()); }
From source file:com.google.plus.wigwamnow.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // If the user is signed in with any SocialProvider, display the Settings option in the // options menu, otherwise clear the menu. switch (currentProvider()) { case SocialProviderConstants.NONE: return false; default:/*from ww w .j a va 2 s . c o m*/ if (menu.size() == 0) { mSettingsId = menu.add(R.string.settings).getItemId(); } return true; } }
From source file:hu.zelena.guide.MainActivity.java
@Override public void onBackPressed() { if (mDrawer.isDrawerOpen(GravityCompat.START)) { mDrawer.closeDrawers();// ww w .j a va2s. c om } else { if (doubleBackToExitPressedOnce) { super.onBackPressed(); return; } Fragment fragment = new AboutFragment(); if (fragment != null) { firstFrag = true; FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit(); setTitle("MOBILTUDS GUIDE"); final Menu menu = nvDrawer.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.hasSubMenu()) { SubMenu subMenu = item.getSubMenu(); for (int j = 0; j < subMenu.size(); j++) { MenuItem subMenuItem = subMenu.getItem(j); subMenuItem.setChecked(false); } } else { item.setChecked(false); } } } else { Intent i = new Intent(this, ErrorActivity.class); i.putExtra("error", "Nem sikerlt a HOME-FRAGMENT betltse. [Null object]"); startActivity(i); Log.e("MainActivity", "Error in creating fragment"); } this.doubleBackToExitPressedOnce = true; Toast.makeText(this, "Nyomja meg mgegyszer a kilpshez", Toast.LENGTH_SHORT).show(); new Handler().postDelayed(new Runnable() { @Override public void run() { doubleBackToExitPressedOnce = false; } }, 2000); } }
From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.ApptentiveBaseFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (toolbarLayoutId != 0) { toolbar = (Toolbar) getActivity().findViewById(toolbarLayoutId); if (getMenuResourceId() != 0 && toolbar != null) { Menu parentMenu = toolbar.getMenu(); ArrayList parentMenuItems = new ArrayList(); // Before creating fragment, host activity may already has menu items on toolbar for (int fragmentMenu = 0; fragmentMenu < parentMenu.size(); ++fragmentMenu) { parentMenuItems.add(Integer.valueOf(parentMenu.getItem(fragmentMenu).getItemId())); }// w w w . j a v a 2 s . co m // Add to toolbar menu items and menu listeners created this fragment toolbar.inflateMenu(getMenuResourceId()); attachFragmentMenuListeners(toolbar.getMenu()); // Menu combinedMenu = toolbar.getMenu(); fragmentMenuItems = new ArrayList(); int colorControlNormal = Util.getThemeColor( ApptentiveInternal.getInstance().getApptentiveToolbarTheme(), R.attr.colorControlNormal); for (int i = 0; i < combinedMenu.size(); ++i) { int menuItemId = combinedMenu.getItem(i).getItemId(); // fragmentMenuItems contains new menu items added by this fragment if (!parentMenuItems.contains(Integer.valueOf(menuItemId))) { fragmentMenuItems.add(Integer.valueOf(menuItemId)); Drawable drawable = combinedMenu.getItem(i).getIcon(); if (drawable != null) { drawable.mutate(); drawable.setColorFilter(colorControlNormal, PorterDuff.Mode.SRC_ATOP); } } } } } }
From source file:org.libreoffice.impressremote.activity.SlideShowActivity.java
private void setMenuItemsVisibility(Menu aMenu, boolean aAreItemsVisible) { for (int aItemIndex = 0; aItemIndex < aMenu.size(); aItemIndex++) { aMenu.getItem(aItemIndex).setVisible(aAreItemsVisible); }//w w w. ja v a 2 s. c o m }
From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java
private void showMenu(final boolean visible) { Menu menu = getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (alwaysShowingMenu.contains(item.getItemId())) continue; item.setVisible(visible);//from w ww . ja v a 2 s. c o m } }
From source file:gov.wa.wsdot.android.wsdot.ui.CameraImageFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.share_action_provider, menu); // Set file with share history to the provider and set the share intent. MenuItem menuItem_Share = menu.findItem(R.id.action_share); shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem_Share); shareAction.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); MenuItem menuItem_Star = menu.add(0, MENU_ITEM_STAR, menu.size(), R.string.description_star); MenuItemCompat.setShowAsAction(menuItem_Star, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); if (mIsStarred) { menu.getItem(MENU_ITEM_STAR).setIcon(R.drawable.ic_menu_star_on); } else {/*w w w .j a v a 2 s . c o m*/ menu.getItem(MENU_ITEM_STAR).setIcon(R.drawable.ic_menu_star); } }
From source file:gov.wa.wsdot.android.wsdot.ui.camera.CameraImageFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.share_action_provider, menu); // Set file with share history to the provider and set the share intent. MenuItem menuItem_Share = menu.findItem(R.id.action_share); shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem_Share); shareAction.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); if (showStar) { MenuItem menuItem_Star = menu.add(0, MENU_ITEM_STAR, menu.size(), R.string.description_star); MenuItemCompat.setShowAsAction(menuItem_Star, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); if (mIsStarred) { menu.getItem(MENU_ITEM_STAR).setIcon(R.drawable.ic_menu_star_on); } else {/*ww w.j a v a 2 s .c om*/ menu.getItem(MENU_ITEM_STAR).setIcon(R.drawable.ic_menu_star); } } }
From source file:com.adnanbal.fxdedektifi.forex.presentation.view.activity.SignalsActivity.java
private void uncheckAllMenuItems(NavigationView navigationView) { final Menu menu = navigationView.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.hasSubMenu()) { SubMenu subMenu = item.getSubMenu(); for (int j = 0; j < subMenu.size(); j++) { MenuItem subMenuItem = subMenu.getItem(j); subMenuItem.setChecked(false); }/*from w ww . j a v a 2 s .c om*/ } else { item.setChecked(false); } } }