List of usage examples for android.view Menu getItem
public MenuItem getItem(int index);
From source file:com.slownet5.pgprootexplorer.filemanager.ui.FileManagerActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { Log.d(TAG, "onPrepareOptionsMenu: preparing menu"); if (SharedData.IS_IN_COPY_MODE) { return super.onPrepareOptionsMenu(menu); }//from ww w . ja v a2s.c o m MenuItem item = menu.getItem(0); if (SharedData.LINEAR_LAYOUTMANAGER) { item.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_gridview)); } return true; }
From source file:es.usc.citius.servando.calendula.activities.CalendarActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.calendar, menu); IconicsDrawable icon = new IconicsDrawable(this, CommunityMaterial.Icon.cmd_information_outline).sizeDp(48) .paddingDp(6).color(Color.WHITE); menu.getItem(0).setIcon(icon); return true;/*from w ww . j av a 2 s . c o m*/ }
From source file:android.hawkencompanionapp.activities.BaseActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.login, menu); final MenuItem menuItemSignOut = menu.findItem(R.id.action_sign_out); final MenuItem menuItemOfflineMode = menu.findItem(R.id.action_offline_mode); //Disable the About option if the current activity is the About activity if (this instanceof AboutActivity) { final MenuItem about = menu.findItem(R.id.action_about); final int len = menu.size(); //Disable all menu items when the about activity is being shown. for (int i = 0; i < len; i++) { final MenuItem item = menu.getItem(i); item.setVisible(false);// ww w. j av a 2 s. co m } } else if (this instanceof ForgotPasswordActvity) { //Forgot Password activity is shown menuItemSignOut.setVisible(false); menuItemOfflineMode.setVisible(false); } else if (this instanceof LoginActivity) { //Login activity is shown menuItemSignOut.setVisible(false); } else if (this instanceof UserAccountMainActivity) { menuItemOfflineMode.setVisible(false); } if (mDisableSignOutOption) { //If the user is in offline mode menuItemSignOut.setVisible(false); } return true; }
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())); }//from w w w. j av a 2s . 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: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 w w . ja v a 2 s . com*/ } else { item.setChecked(false); } } }
From source file:com.mifos.mifosxdroid.online.SavingsAccountSummaryFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { menu.clear();/* w ww .ja va2 s . c om*/ menu.addSubMenu(Menu.NONE, MENU_ITEM_DATA_TABLES, Menu.NONE, Constants.DATA_TABLE_SAVINGS_ACCOUNTS_NAME); menu.add(Menu.NONE, MENU_ITEM_DOCUMENTS, Menu.NONE, getResources().getString(R.string.documents)); // This is the ID of Each data table which will be used in onOptionsItemSelected Method int SUBMENU_ITEM_ID = 0; // Create a Sub Menu that holds a link to all data tables SubMenu dataTableSubMenu = menu.getItem(1).getSubMenu(); if (dataTableSubMenu != null && savingsAccountDataTables != null && savingsAccountDataTables.size() > 0) { Iterator<DataTable> dataTableIterator = savingsAccountDataTables.iterator(); while (dataTableIterator.hasNext()) { dataTableSubMenu.add(Menu.NONE, SUBMENU_ITEM_ID, Menu.NONE, dataTableIterator.next().getRegisteredTableName()); SUBMENU_ITEM_ID++; } } super.onPrepareOptionsMenu(menu); }
From source file:com.example.volunteerhandbook.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (!noDrawYet && mDrawerLayout != null) mDrawerLayout.isDrawerOpen(mDrawerList); for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setVisible(false); }/* w ww . ja v a 2 s . c o m*/ //menu.findItem(R.id.action_websearch).setVisible(!drawerOpen); mActionMenu = menu; return super.onPrepareOptionsMenu(menu); }
From source file:com.github.shareme.gwsmaterialuikit.library.material.app.ToolbarManager.java
/** * This function should be called in onPrepareOptionsMenu(Menu) of Activity that use * Toolbar as ActionBar, or after inflating menu. *//*from w ww . j a v a 2 s . co m*/ public void onPrepareMenu() { if (mGroupChanged || mMenuDataChanged) { mToolbar.getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener); Menu menu = mToolbar.getMenu(); for (int i = 0, count = menu.size(); i < count; i++) { MenuItem item = menu.getItem(i); item.setVisible(item.getGroupId() == mCurrentGroup || item.getGroupId() == 0); } mMenuDataChanged = false; } }
From source file:com.pacoapp.paco.ui.FindExperimentsActivity.java
@SuppressLint("NewApi") @Override/*ww w . j a v a 2 s . c om*/ public boolean onCreateOptionsMenu(Menu menu) { int pos = 1; if (true || !mNavigationDrawerFragment.isDrawerOpen()) { getMenuInflater().inflate(R.menu.main, menu); //restoreActionBar(); // TODO hide find experiments (this is that item) // TODO make refresh be an always action MenuItem findExperiments = menu.getItem(0); findExperiments.setVisible(false); MenuItem refreshExperiments = menu.getItem(1); refreshExperiments.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); return true; } return super.onCreateOptionsMenu(menu); }
From source file:net.gsantner.opoc.util.ContextUtils.java
/** * Try to tint all {@link Menu}s {@link MenuItem}s with given color *//*from w w w . j a v a 2 s . c o m*/ @SuppressWarnings("ConstantConditions") public void tintMenuItems(Menu menu, boolean recurse, @ColorInt int iconColor) { for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); try { tintDrawable(item.getIcon(), iconColor); if (item.hasSubMenu() && recurse) { tintMenuItems(item.getSubMenu(), recurse, iconColor); } } catch (Exception ignored) { // This should not happen at all, but may in bad menu.xml configuration } } }