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.loopj.android.http.sample.Redirect302Sample.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem menuItemEnableRedirects = menu.findItem(0);
    if (menuItemEnableRedirects != null)
        menuItemEnableRedirects.setChecked(enableRedirects);
    MenuItem menuItemEnableRelativeRedirects = menu.findItem(1);
    if (menuItemEnableRelativeRedirects != null)
        menuItemEnableRelativeRedirects.setChecked(enableRelativeRedirects);
    MenuItem menuItemEnableCircularRedirects = menu.findItem(2);
    if (menuItemEnableCircularRedirects != null)
        menuItemEnableCircularRedirects.setChecked(enableCircularRedirects);
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.android.deskclock.actionbarmenu.SearchMenuItemController.java

@Override
public void setInitialState(Menu menu) {
    super.setInitialState(menu);
    final MenuItem search = menu.findItem(SEARCH_MENU_RES_ID);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(search);
    searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    searchView.setQuery(mQuery, false);/*from  w  w  w.  j a v  a 2  s.  c  o  m*/
    searchView.setOnCloseListener(mSearchModeChangeListener);
    searchView.setOnSearchClickListener(mSearchModeChangeListener);
    searchView.setOnQueryTextListener(mQueryListener);
    if (mSearchMode) {
        searchView.requestFocus();
        searchView.setIconified(false);
    }
}

From source file:cn.jarlen.mediaplayer.sample.activities.RecentMediaActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    boolean show = super.onPrepareOptionsMenu(menu);
    if (!show)//from   w ww.  ja  v a 2  s  . c om
        return show;

    MenuItem item = menu.findItem(R.id.action_recent);
    if (item != null)
        item.setVisible(false);

    return true;
}

From source file:at.wada811.android.library.demos.loader.LoaderListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_search, menu);
    initSearchView(menu.findItem(R.id.search));
    return true;/*w w  w  .j av a  2  s  .  com*/
}

From source file:de.elanev.studip.android.app.frontend.forums.ForumEntryComposeFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    menu.findItem(R.id.create_new_area).setVisible(mSendButtonVisible);

    ((AppCompatActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(!mSendButtonVisible);
}

From source file:com.android.dialer.calllog.CallLogActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    final MenuItem itemDeleteAll = menu.findItem(R.id.delete_all);

    // If onPrepareOptionsMenu is called before fragments loaded. Don't do anything.
    if (mAllCallsFragment != null && itemDeleteAll != null) {
        final CallLogAdapter adapter = mAllCallsFragment.getAdapter();
        itemDeleteAll.setVisible(adapter != null && !adapter.isEmpty());
    }//from   ww w.  j a  v  a  2s.  c om
    return true;
}

From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java

public static void setPartyShuffleMenuIcon(Menu menu) {
    MenuItem item = menu.findItem(Defs.PARTY_SHUFFLE);
    if (item != null) {
        int shuffle = MusicUtils.getCurrentShuffleMode();
        if (shuffle == MediaPlaybackService.SHUFFLE_AUTO) {
            item.setIcon(R.drawable.ic_menu_party_shuffle);
            item.setTitle(R.string.party_shuffle_off);
        } else {//from w w  w.jav  a 2  s.  com
            item.setIcon(R.drawable.ic_menu_party_shuffle);
            item.setTitle(R.string.party_shuffle);
        }
    }
}

From source file:at.bitfire.davdroid.syncadapter.AccountDetailsFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    boolean ok = false;
    ok = editAccountName.getText().length() > 0;
    MenuItem item = menu.findItem(R.id.add_account);
    item.setEnabled(ok);/*from  www.  j  a  v a 2  s . c o m*/
}

From source file:bbct.android.common.activity.FilterCards.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    MenuItem confirm = menu.findItem(R.id.save_menu);

    if (this.numberChecked() > 0) {
        confirm.setVisible(true);/*from w ww.  ja  v a2s .c  o m*/
        confirm.setEnabled(true);
    } else {
        confirm.setVisible(false);
        confirm.setEnabled(false);
    }
}

From source file:android.support.test.testapp.ActionBarSearchActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    inflater.inflate(R.menu.actionbar_search_actions, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
    return super.onCreateOptionsMenu(menu);
}