List of usage examples for android.view Menu getItem
public MenuItem getItem(int index);
From source file:org.cvasilak.jboss.mobile.app.fragments.AttributeEditorFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { // disable 'Save' button if the attribute is 'read-only' if (attr.isReadOnly()) menu.getItem(0).setEnabled(false); }
From source file:de.vanita5.twittnuker.util.ThemeUtils.java
public static void applyColorFilterToMenuIcon(final Menu menu, final int color, final int popupColor, final int highlightColor, final Mode mode, final int... excludedGroups) { for (int i = 0, j = menu.size(); i < j; i++) { final MenuItem item = menu.getItem(i); final Drawable icon = item.getIcon(); final ContextMenuInfo info = item.getMenuInfo(); if (icon != null && !ArrayUtils.contains(excludedGroups, item.getGroupId())) { icon.mutate();/*from w ww.j av a2 s . c o m*/ if (info instanceof TwidereMenuInfo) { final TwidereMenuInfo sInfo = (TwidereMenuInfo) info; icon.setColorFilter(sInfo.isHighlight() ? sInfo.getHighlightColor(highlightColor) : color, mode); } else { icon.setColorFilter(color, mode); } } if (item.hasSubMenu()) { // SubMenu item is always in popup applyColorFilterToMenuIcon(item.getSubMenu(), popupColor, popupColor, highlightColor, mode, excludedGroups); } } }
From source file:pt.ubi.di.pdm.swipe.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.getItem(1).getSubMenu().getItem(1).setEnabled(false); menu.getItem(1).getSubMenu().getItem(2).setEnabled(false); menu.getItem(1).getSubMenu().getItem(3).setEnabled(false); menu.getItem(0).setVisible(false);//w ww.jav a2 s. c o m menu.getItem(2).setVisible(false); return true; }
From source file:tm.alashow.datmusic.ui.activity.BaseActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { for (int i = 0; i < menu.size(); i++) menu.getItem(i).setVisible(!shouldGoInvisible); return super.onPrepareOptionsMenu(menu); }
From source file:id.zelory.codepolitan.ui.fragment.ListArticleFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); searchView = (SearchView) menu.getItem(0).getActionView(); searchView.setOnQueryTextListener(this); }
From source file:com.example.jony.myapp.reader_APP.ui.ReadingDetailsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_ebook, menu); if (Utils.hasString(bookBean.getEbook_url()) == false) menu.getItem(0).setVisible(false); return true;//from ww w .j a va2s . com }
From source file:org.chromium.chrome.browser.preferences.Preferences.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (menu.size() == 1) { MenuItem item = menu.getItem(0); if (item.getIcon() != null) item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); }//from ww w .ja v a 2 s . co m return super.onPrepareOptionsMenu(menu); }
From source file:org.getlantern.firetweet.util.ThemeUtils.java
public static void applyColorFilterToMenuIcon(final Menu menu, final int color, final int popupColor, final int highlightColor, final Mode mode, final int... excludedGroups) { for (int i = 0, j = menu.size(); i < j; i++) { final MenuItem item = menu.getItem(i); final Drawable icon = item.getIcon(); final ContextMenuInfo info = item.getMenuInfo(); if (icon != null && !ArrayUtils.contains(excludedGroups, item.getGroupId())) { icon.mutate();/*from w w w .j av a2 s . com*/ if (info instanceof FiretweetMenuInfo) { final FiretweetMenuInfo sInfo = (FiretweetMenuInfo) info; icon.setColorFilter(sInfo.isHighlight() ? sInfo.getHighlightColor(highlightColor) : color, mode); } else { icon.setColorFilter(color, mode); } } if (item.hasSubMenu()) { // SubMenu item is always in popup applyColorFilterToMenuIcon(item.getSubMenu(), popupColor, popupColor, highlightColor, mode, excludedGroups); } } }
From source file:com.github.jvanhie.discogsscrobbler.DrawerActivity.java
/*** * Called when invalidateOptionsMenu() is triggered *//*from w ww . j a v a 2s. c o m*/ @Override public boolean onPrepareOptionsMenu(Menu menu) { // if nav drawer is opened, hide the action items boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList); for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setVisible(!drawerOpen); } return super.onPrepareOptionsMenu(menu); }
From source file:us.koller.todolist.Activities.InfoActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_info, menu); menu.getItem(0).getIcon().setColorFilter(helper.getToolbarIconColor(), PorterDuff.Mode.SRC_IN); return true;/* w ww . ja v a 2 s.co m*/ }