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:eu.iescities.pilot.rovereto.roveretoexplorer.fragments.search.SearchFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();/*from w ww .  j a  v  a  2 s.c  o m*/
    Log.i("MENU", "load gripmenu!!!!");
    getActivity().getMenuInflater().inflate(R.menu.gripmenu, menu);

    SubMenu submenu = menu.getItem(0).getSubMenu();
    submenu.clear();

    super.onPrepareOptionsMenu(menu);
}

From source file:com.jaspersoft.android.jaspermobile.ui.view.activity.NavigationActivity.java

private void hideMenuItems(Menu menu, boolean visible) {
    for (int i = 0; i < menu.size(); i++) {
        menu.getItem(i).setVisible(visible);
    }//from   www.j a va  2  s  .c o m
}

From source file:click.kobaken.rxirohaandroid_sample.view.activity.MainActivity.java

private void allClearBottomNavigationMenuChecked() {
    Menu menu = binding.bottomNavigation.getMenu();
    for (int i = 0; i < menu.size(); i++) {
        menu.getItem(i).setChecked(false);
    }// ww  w  .  jav  a  2 s.c om
}

From source file:com.arcgis.android.samples.localdata.localrasterdata.FileBrowserFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        if ((item.getItemId() == R.id.menu_layer_raster) || (item.getItemId() == R.id.menu_renderer)
                || (item.getItemId() == R.id.menu_dir_select)) {
            item.setVisible(false);/*  ww  w .j  a  v a  2s  .  co  m*/
        } else if ((item.getItemId() == R.id.menu_dir_up)) {
            item.setVisible(true);
        }
    }
}

From source file:com.listapp.ListappActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);
    // Invoke the Register activity
    menu.getItem(0).setIntent(new Intent(this, AccountsActivity.class));
    return true;/* w  w w  .  j a  v  a2s .co  m*/
}

From source file:com.notriddle.budget.EnvelopesActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    boolean drawerOpen = mDrawerLayout.isDrawerOpen(mNavDrawer);
    int l = menu.size();
    for (int i = 0; i != l; ++i) {
        menu.getItem(i).setVisible(!drawerOpen);
    }/*from   w w  w  .j  av  a 2s. c  om*/
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.google.reviewit.DetailedChangeFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    SortActionHandler actionHandler = getApp().getSortActionHandler();
    inflater.inflate(R.menu.menu_detailed_change, menu);
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        if (item.getItemId() == R.id.action_abandon) {
            item.setVisible(actionHandler.hasCurrentChange()
                    && (actionHandler.getCurrentChange().info.status == ChangeStatus.NEW
                            || actionHandler.getCurrentChange().info.status == ChangeStatus.SUBMITTED));
        } else if (item.getItemId() == R.id.action_restore) {
            item.setVisible(actionHandler.hasCurrentChange()
                    && actionHandler.getCurrentChange().info.status == ChangeStatus.ABANDONED);
        }//from w ww .j a v  a 2 s. c o  m
    }
}

From source file:com.joaquimley.faboptions.FabOptions.java

private void addButtonsFromMenu(Context context, Menu menu) {
    for (int i = 0; i < menu.size(); i++) {
        addButton(context, menu.getItem(i));
    }/*ww  w  .ja va  2s.c o m*/
}

From source file:com.tagaugmentedreality.Lists.java

@SuppressLint("NewApi")
@Override//ww w .j  ava 2  s .c o m
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_lists, menu);

    /**
     * The progress bar is at position 1 of the menu.
     */
    progressBar = menu.getItem(1);
    progressBar.setActionView(R.layout.progress_bar);

    return true;
}

From source file:de.baumann.hhsmoodle.HHS_MainScreen.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {

    if (sharedPref.getBoolean("help", false)) {
        menu.getItem(0).setVisible(false); // here pass the index of save menu item
    }// w ww  .j  a  v  a2  s. c  o m
    return super.onPrepareOptionsMenu(menu);
}