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:org.sufficientlysecure.localcalendar.ui.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);

    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        menu.getItem(menu.size() - 1).setEnabled(false);
    }/*from   w ww . j  ava  2  s.  c o  m*/

    return true;
}

From source file:syncthing.android.ui.LauncherActivity.java

void clearCheckedMenuItems() {
    Menu menu = mNavigation.getMenu();
    for (int ii = 0; ii < menu.size(); ii++) {
        menu.getItem(ii).setChecked(false);
    }/*from   w  ww.j a va2 s  . c  o m*/
}

From source file:eu.trentorise.smartcampus.trentinofamiglia.fragments.search.SearchFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();/*from  ww  w  .  j  ava2s  .co  m*/
    getActivity().getMenuInflater().inflate(R.menu.gripmenu, menu);

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

    super.onPrepareOptionsMenu(menu);
}

From source file:de.aw.monma.actions.FragmentWPList.java

/**
 * Bei Click wird das contextmenu gezeigt. In den jeweiligen extras sind folgende Informationen
 * enthalten: WPID, AMOUNT, WPNAME des gewaehlten Wertpapiers.
 *//*  w w w.  ja  v a2  s  .com*/
@Override
public void onRecyclerItemClick(View view, int position, WertpapierListItem item) {
    super.onRecyclerItemClick(view, position, item);
    Intent intent = new Intent();
    intent.putExtra(WPID, item.getID());
    intent.putExtra(WPNAME, item.getWPName());
    intent.putExtra(ACCOUNTID, NOID);
    intent.putExtra(AMOUNT, item.getGewinn());
    PopupMenu popUpMenu = new PopupMenu(getActivity(), view);
    popUpMenu.inflate(R.menu.context_fragment_wpuebersicht);
    popUpMenu.inflate(R.menu.context_fragment_wpliste);
    Menu menu = popUpMenu.getMenu();
    for (int i = 0; i < menu.size(); i++) {
        menu.getItem(i).setIntent(intent);
    }
    popUpMenu.setOnMenuItemClickListener(this);
    popUpMenu.show();
}

From source file:net.wespot.pim.compat.view.InqDataCollectionTaskCompatFragment.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.menu_data_collection, menu);

    setEnabledDisabled(menu.getItem(0), isDataCollectionPicture);
    setEnabledDisabled(menu.getItem(1), isDataCollectionVideo);
    setEnabledDisabled(menu.getItem(2), isDataCollectionAudio);
    setEnabledDisabled(menu.getItem(3), isDataCollectionText);
    setEnabledDisabled(menu.getItem(4), isDataCollectionValue);

    return super.onCreateOptionsMenu(menu);
}

From source file:com.soil.soilsample.ui.main.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.action_add_sample) || (item.getItemId() == R.id.menu_dir_select)
                || (item.getItemId() == R.id.action_upload)) {
            item.setVisible(false);//w  ww  . j a  v a2 s .  c o  m
        } else if ((item.getItemId() == R.id.menu_dir_up)) {
            item.setVisible(true);
        }
    }
}

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

private void allClearNavigationMenuChecked() {
    Menu menu = binding.navigation.getMenu();
    for (int i = 0; i < menu.size(); i++) {
        menu.getItem(i).setChecked(false);
    }/* w  w  w  .ja  v a  2 s. c o m*/
}

From source file:com.refujiate.ui.MainMapaActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    clsPersona objPersona = clsPersonalSQL.Buscar(this);
    if (objPersona == null)
        menu.getItem(4).setVisible(false);
    else/*from ww w .j ava2 s. c om*/
        menu.getItem(4).setVisible(true);
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.white.bihudaily.module.dailys.DailyActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    if ((boolean) SPUtils.get(this, Constant.KEY_NIGHT, false)) {
        menu.getItem(1).setTitle(R.string.action_day_mode);
    }//from   w w w  . j a v  a  2  s .com
    return true;
}

From source file:ie.tcd.scss.dsg.particpatory.SampleListFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Menu menu = newMenuInstance(getActivity());

    if (menu != null) {
        new MenuInflater(getActivity()).inflate(R.menu.sliding_menu, menu);
        MenuListAdapter adapter = new MenuListAdapter(getActivity());
        for (int i = 0; i < menu.size(); i++) {
            MenuItem item = menu.getItem(i);
            adapter.add(new SampleItem(item.getTitle().toString(), item.getIcon()));
        }//  w  ww . j  av a 2s  .  c  o m

        setListAdapter(adapter);

    } else {
        TextView emptyText = new TextView(getActivity());
        emptyText.setText("No Menu");
        getListView().setEmptyView(emptyText);
    }
    ListView listView = new ListView(getActivity());
    listView.setId(android.R.id.list);
    return listView;
}