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.krayzk9s.imgurholo.ui.CommentsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    if (activity.getApiCall().settings.getString("theme", MainActivity.HOLO_LIGHT)
            .equals(MainActivity.HOLO_LIGHT))
        inflater.inflate(R.menu.main, menu);
    else//  w  ww.ja v a 2s  . c  o m
        inflater.inflate(R.menu.main_dark, menu);
    menu.findItem(R.id.action_upload).setVisible(false);
    menu.findItem(R.id.action_refresh).setVisible(true);
}

From source file:com.orange.ocara.ui.activity.ListAuditActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean ret = super.onCreateOptionsMenu(menu);

    searchMenuItem = menu.findItem(com.orange.ocara.R.id.action_search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);

    if (searchView != null) {
        searchView.setIconifiedByDefault(true);
        searchView.setOnQueryTextListener(this);
    }//  w w  w  . j  a v  a 2  s .c o m

    MenuItemCompat.setOnActionExpandListener(searchMenuItem, this);
    return ret;
}

From source file:app.umitems.greenclock.DeskClock.java

private void updateMenu(Menu menu) {
    // Hide "help" if we don't have a URI for it.
    MenuItem help = menu.findItem(R.id.menu_item_help);
    if (help != null) {
        Utils.prepareHelpMenuItem(this, help);
    }/*ww  w  . j ava2  s. c  o  m*/

    // Hide "lights out" for timer.
    MenuItem nightMode = menu.findItem(R.id.menu_item_night_mode);
    if (mActionBar.getSelectedNavigationIndex() == ALARM_TAB_INDEX) {
        nightMode.setVisible(false);
    } else if (mActionBar.getSelectedNavigationIndex() == CLOCK_TAB_INDEX) {
        nightMode.setVisible(true);
    }
}

From source file:be.brunoparmentier.openbikesharing.app.activities.StationsListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    this.optionsMenu = menu;
    getMenuInflater().inflate(R.menu.stations_list, menu);

    SearchManager manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);

    searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSearchableInfo(manager.getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override//  w  w w.ja v a  2 s .c  o m
        public boolean onQueryTextSubmit(String s) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            loadData(s);
            return true;
        }
    });

    return true;
}

From source file:com.android.calendar.SearchActivity.java

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

    // replace the default top layer drawable of the today icon with a custom drawable
    // that shows the day of the month of today
    MenuItem menuItem = menu.findItem(R.id.action_today);
    if (Utils.isJellybeanOrLater()) {
        LayerDrawable icon = (LayerDrawable) menuItem.getIcon();
        Utils.setTodayIcon(icon, this, Utils.getTimeZone(SearchActivity.this, mTimeChangesUpdater));
    } else {// www .  j  a  v a 2 s . c o m
        menuItem.setIcon(R.drawable.ic_menu_today_no_date_holo_light);
    }

    MenuItem item = menu.findItem(R.id.action_search);

    MenuItemCompat.expandActionView(item);
    MenuItemCompat.setOnActionExpandListener(item, this);
    mSearchView = (SearchView) MenuItemCompat.getActionView(item);
    Utils.setUpSearchView(mSearchView, this);
    mSearchView.setQuery(mQuery, false);
    mSearchView.clearFocus();

    return true;
}

From source file:com.android.deskclock.worldclock.CitiesActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem sortMenuItem = menu.findItem(R.id.menu_item_sort);
    if (mSortType == SORT_BY_NAME) {
        sortMenuItem.setTitle(getString(R.string.menu_item_sort_by_gmt_offset));
    } else {//  w w  w . j av a  2s .c o m
        sortMenuItem.setTitle(getString(R.string.menu_item_sort_by_name));
    }
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.microsoft.onenote.pickerlib.OneNotePickerActivity.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.menu_onenote_picker, menu);

    if (mNavTextColor != -1) {
        menu.findItem(R.id.action_close)
                .setIcon(UiUtility.colorizedDrawable(this, mNavTextColor, R.drawable.ic_action_close_dark));
    }//  w w  w .  j av a  2  s .c o  m

    return true;
}

From source file:io.radio.streamer.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    // If the nav drawer is open, hide action items related to the content view
    boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
    menu.findItem(R.id.action_search).setVisible(!drawerOpen);
    return super.onPrepareOptionsMenu(menu);
}

From source file:cl.mmoscoso.geocomm.GeoCommMainActivity.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.map_view_main, menu);
    //SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    //menu.findItem(R.id.action_search).getActionView();
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
    searchView.setOnQueryTextListener(this);
    return true;// w  ww  .ja va 2s .  co  m
}