Example usage for android.view Menu getItem

List of usage examples for android.view Menu getItem

Introduction

In this page you can find the example usage for android.view Menu getItem.

Prototype

public MenuItem getItem(int index);

Source Link

Document

Gets the menu item at the given index.

Usage

From source file:com.github.guilhermesgb.marqueeto.sample.DriversLicenseActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_drivers_license_activity, menu);
    menu.getItem(0)
            .setIcon(new IconDrawable(this, "md-note-add").actionBarSize().colorRes(android.R.color.white));
    menu.getItem(1)/*from ww  w .ja v a2s  .  c  o  m*/
            .setIcon(new IconDrawable(this, "md-settings").actionBarSize().colorRes(android.R.color.white));
    return true;
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static void wrapMenuIcon(@NonNull Menu menu, int itemColor, int subItemColor, int... excludeGroups) {
    for (int i = 0, j = menu.size(); i < j; i++) {
        final MenuItem item = menu.getItem(i);
        wrapMenuItemIcon(item, itemColor, excludeGroups);
        if (item.hasSubMenu()) {
            wrapMenuIcon(item.getSubMenu(), subItemColor, subItemColor, excludeGroups);
        }/*from   www.j a  v  a  2 s.  co m*/
    }
}

From source file:id.zelory.codepolitan.ui.fragment.AbstractHomeFragment.java

private void onMenuCreated(Menu menu) {
    searchView = (SearchView) menu.getItem(0).getActionView();
    searchView.setOnQueryTextListener(this);
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static void wrapMenuIcon(ActionMenuView view, int... excludeGroups) {
    final int itemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext());
    final int popupItemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext(),
            view.getPopupTheme());//  w  ww  . ja  va2s.  c o m
    final Resources resources = view.getResources();
    final int colorDark = resources.getColor(R.color.action_icon_dark);
    final int colorLight = resources.getColor(R.color.action_icon_light);
    final int itemColor = ColorUtils.getContrastYIQ(itemBackgroundColor, colorDark, colorLight);
    final int popupItemColor = ColorUtils.getContrastYIQ(popupItemBackgroundColor, colorDark, colorLight);
    final Menu menu = view.getMenu();
    final int childCount = view.getChildCount();
    for (int i = 0, j = menu.size(), k = 0; i < j; i++) {
        final MenuItem item = menu.getItem(i);
        wrapMenuItemIcon(item, itemColor, excludeGroups);
        if (item.hasSubMenu()) {
            wrapMenuIcon(menu, popupItemColor, popupItemColor, excludeGroups);
        }
        if (item.isVisible()) {
            k++;
        }
    }

}

From source file:com.app.blockydemo.ui.fragment.FormulaEditorListFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    for (int index = 0; index < menu.size(); index++) {
        menu.getItem(index).setVisible(false);
    }//from   w ww  .ja v  a 2s .  c  om

    getActivity().getActionBar().setDisplayShowTitleEnabled(true);
    getActivity().getActionBar().setTitle(actionBarTitle);
    getActivity().getActionBar().setDisplayHomeAsUpEnabled(false);

    super.onPrepareOptionsMenu(menu);
}

From source file:br.unisinos.evertonlucas.passshelter.app.ResourceActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (isFinalized) {
        menu.getItem(0).setEnabled(!insercao);
        menu.getItem(1).setEnabled(!insercao);
    }//from w ww.j  a v a2 s  .c om
    return true;
}

From source file:com.church.psalm.view.activity.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    _sort = menu.getItem(0);
    _search = menu.getItem(1);//  w  w  w.j  a v a 2s  .  co m
    _category = menu.getItem(2);
    return true;
}

From source file:org.getlantern.firetweet.util.ThemeUtils.java

public static void wrapMenuIcon(ActionMenuView view, int... excludeGroups) {
    final int itemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext());
    final int popupItemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext(),
            view.getPopupTheme());/*from w  w w  .  jav a2  s  .  co  m*/
    final Resources resources = view.getResources();
    final int colorDark = resources.getColor(R.color.action_icon_dark);
    final int colorLight = resources.getColor(R.color.action_icon_light);
    final int itemColor = ColorUtils.getContrastYIQ(itemBackgroundColor, colorDark, colorLight);
    final int popupItemColor = ColorUtils.getContrastYIQ(popupItemBackgroundColor, colorDark, colorLight);
    final Menu menu = view.getMenu();
    final int childCount = view.getChildCount();
    for (int i = 0, j = menu.size(), k = 0; i < j; i++) {
        final MenuItem item = menu.getItem(i);
        wrapMenuItemIcon(item, itemColor, excludeGroups);
        if (item.hasSubMenu()) {
            wrapMenuIcon(menu, popupItemColor, popupItemColor, excludeGroups);
        }
        if (item.isVisible()) {
            k++;
        }
    }
}

From source file:com.cryart.sabbathschool.view.SSQuarterliesActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.ss_quarterlies_menu, menu);
    menu.getItem(0).setIcon(
            new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_translate).color(Color.WHITE).sizeDp(18));
    return true;/*from   w  ww.  j  a  v  a  2 s .  com*/
}

From source file:com.jefftharris.passwdsafe.FileListNavDrawerFragment.java

/**
 * Update drawer for the fragments displayed in the activity
 *//*w  ww.ja v a  2  s .co  m*/
public void updateView(Mode mode) {
    boolean openDrawer = false;
    NavMenuItem selNavItem = null;
    switch (mode) {
    case INIT: {
        break;
    }
    case ABOUT: {
        selNavItem = NavMenuItem.ABOUT;
        break;
    }
    case FILES: {
        // If the user hasn't 'learned' about the drawer, open it
        openDrawer = shouldOpenDrawer();
        selNavItem = NavMenuItem.FILES;
        break;
    }
    case PREFERENCES: {
        selNavItem = NavMenuItem.PREFERENCES;
        break;
    }
    }

    updateDrawerToggle(true, 0);

    Menu menu = getNavView().getMenu();
    for (int i = 0; i < menu.size(); ++i) {
        MenuItem item = menu.getItem(i);
        int itemId = item.getItemId();
        if (selNavItem == null) {
            item.setChecked(false);
        } else if (selNavItem.itsMenuId == itemId) {
            item.setChecked(true);
        }
    }
    itsSelNavItem = selNavItem;

    openDrawer(openDrawer);
}