Example usage for android.view Menu findItem

List of usage examples for android.view Menu findItem

Introduction

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

Prototype

public MenuItem findItem(int id);

Source Link

Document

Return the menu item with a particular identifier.

Usage

From source file:com.free.underground.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
    menu.findItem(R.id.action_websearch).setVisible(!drawerOpen);
    return super.onPrepareOptionsMenu(menu);
}

From source file:cf.charly1811.android.sample.MediaRouteProvider.MainActivity.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.main, menu);
    MenuItem media_route_menu_item = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider provider = (MediaRouteActionProvider) MenuItemCompat
            .getActionProvider(media_route_menu_item);
    provider.setRouteSelector(mediaRouteSelector);
    return true;//from   w  w w .jav a  2s. co m
}

From source file:ca.rmen.android.palidamuerte.app.category.list.CategoriesActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Log.v(TAG, "onCreateOptionsMenu");
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_categories, menu);
    ActionBar.updateMusicMenuItem(this, menu.findItem(R.id.action_music));
    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    return true;//from  w  ww.ja va2 s .  com
}

From source file:behsaman.storytellerandroid.TextviewerSlideActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.screen_slide, menu);

    menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);

    // Add either a "next" or "finish" button to the action bar, depending on which page
    // is currently selected.
    MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? "Finish" : "Next");
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;/*from   www  .j  a  v a 2  s  .  co  m*/
}

From source file:at.bitfire.nophonespam.BlacklistActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.findItem(R.id.block_hidden_numbers).setChecked(settings.blockHiddenNumbers());
    menu.findItem(R.id.notifications).setChecked(settings.showNotifications());
    return true;//from   ww  w.j av  a 2  s.  c  om
}

From source file:MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_options, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    return true;//  ww w  . j  a va2 s. c o m
}

From source file:com.agenmate.lollipop.addedit.AddEditActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.add_edit_actions, menu);
    this.menu = menu;
    alarmIcon = menu.findItem(R.id.action_alarm);
    alarmIcon.setVisible(false);//  w w  w.  j a  va2 s .co m
    if (taskId == null)
        menu.findItem(R.id.action_delete).setVisible(false);
    addEditFragment.onOptionsCreated();

    return super.onCreateOptionsMenu(menu);
}

From source file:com.smartx.bill.mepad.mestore.uimgloader.AbsListViewBaseActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem pauseOnScrollItem = menu.findItem(R.id.item_pause_on_scroll);
    pauseOnScrollItem.setVisible(true);/*from w  w  w.  jav a 2s  .  c  o m*/
    pauseOnScrollItem.setChecked(pauseOnScroll);

    MenuItem pauseOnFlingItem = menu.findItem(R.id.item_pause_on_fling);
    pauseOnFlingItem.setVisible(true);
    pauseOnFlingItem.setChecked(pauseOnFling);
    return true;
}

From source file:ca.rmen.android.poetassistant.main.dictionaries.ResultListFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    menu.findItem(R.id.action_share).setEnabled(mAdapter.getItemCount() > 0);
}

From source file:fr.bmartel.android.iotf.app.BaseActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    if (menu.findItem(R.id.disconnect_button) != null)
        menu.findItem(R.id.disconnect_button).setVisible(isShowingDisconnectBtn());
    if (menu.findItem(R.id.notification_button) != null)
        menu.findItem(R.id.notification_button).setVisible(isShowingNotificationBtn());
    if (menu.findItem(R.id.edit_phone_notification) != null)
        menu.findItem(R.id.edit_phone_notification).setVisible(isShowingEditPhoneNotification());
    displayDisconnect(menu.findItem(R.id.disconnect_button));
    return true;/*from   www .  java2  s .  c o m*/
}