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:fr.cph.chicago.activity.StationActivity.java

@Override
public final boolean onCreateOptionsMenu(final Menu menu) {
    super.onCreateOptionsMenu(menu);
    this.mMenu = menu;
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_no_search, menu);

    MenuItem refreshMenuItem = menu.findItem(R.id.action_refresh);
    refreshMenuItem.setActionView(R.layout.progressbar);
    refreshMenuItem.expandActionView();/*from w  ww. ja v a2  s .  c  o  m*/

    return true;
}

From source file:com.push.app.HomeActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    mSearchAction = menu.findItem(R.id.action_search);
    mAboutAction = menu.findItem(R.id.action_about);
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.orbar.pxdemo.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //inflate menu and attach the search listener

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);

    searchItem = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) searchItem.getActionView();
    mSearchView.setQueryHint(getResources().getText(R.string.search_hint));

    mSearchView.setOnQueryTextListener(new searchQueryListener());

    return super.onCreateOptionsMenu(menu);
}

From source file:com.dahl.brendan.wordsearch.view.WordSearchActivity.java

/** hook into menu button for activity */
@Override// www .  ja v a2  s.  c om
public boolean onCreateOptionsMenu(Menu menu) {
    this.getMenuInflater().inflate(R.menu.wordsearch_options, menu);
    menu.findItem(R.id.menu_new).setIcon(android.R.drawable.ic_menu_add);
    menu.findItem(R.id.menu_options).setIcon(android.R.drawable.ic_menu_preferences);
    menu.findItem(R.id.menu_custom).setIcon(android.R.drawable.ic_menu_edit);
    menu.findItem(R.id.menu_tutorial).setIcon(android.R.drawable.ic_menu_help);
    menu.findItem(R.id.menu_scores).setIcon(android.R.drawable.ic_menu_gallery);
    menu.findItem(R.id.menu_donate).setIcon(R.drawable.love);
    return super.onCreateOptionsMenu(menu);
}

From source file:ws.crandell.newspaperpuzzles.wordsearch.view.WordSearchActivity.java

/** hook into menu button for activity */
@Override//from   w  ww .  ja  va2 s. com
public boolean onCreateOptionsMenu(Menu menu) {
    this.getMenuInflater().inflate(R.menu.ws_wordsearch_options, menu);
    menu.findItem(R.id.menu_new).setIcon(android.R.drawable.ic_menu_add);
    menu.findItem(R.id.menu_options).setIcon(android.R.drawable.ic_menu_preferences);
    menu.findItem(R.id.menu_custom).setIcon(android.R.drawable.ic_menu_edit);
    menu.findItem(R.id.menu_tutorial).setIcon(android.R.drawable.ic_menu_help);
    menu.findItem(R.id.menu_scores).setIcon(android.R.drawable.ic_menu_gallery);
    menu.findItem(R.id.menu_donate).setIcon(R.drawable.ws_love);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.repkap11.repcast.activities.LocalPlayerActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.findItem(R.id.action_show_queue).setVisible(mCastManager.isConnected());
    return super.onPrepareOptionsMenu(menu);
}

From source file:cn.tycoon.lighttrans.fileManager.AbstractFilePickerFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.picker_actions, menu);

    MenuItem item = menu.findItem(R.id.action_createdir);
    item.setVisible(allowCreateDir);// ww w .  j  av  a 2 s .co  m
}

From source file:com.amti.vela.bluetoothlegatt.bluetooth.DeviceScanActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_device_search, menu);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        //menu.findItem(R.id.menu_search).getIcon().setTint(ContextCompat.getColor(this, R.color.action_button_dark_blue));
    }//  w w  w . jav  a 2 s .  c o m

    if (!mScanning) {
        swipeContainer.setRefreshing(false);
    }
    if (disableActionButton)
        menu.findItem(R.id.menu_search).setEnabled(false);
    else
        menu.findItem(R.id.menu_search).setEnabled(true);
    return true;
}

From source file:com.hybris.mobile.activity.AbstractProductDetailActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate menu
    MenuUtil.onCreateProductDetailsOptionsMenu(menu, this);
    menu.removeItem(R.id.search);//w w w . j  av a2  s .  c  om

    if (!getResources().getBoolean(R.bool.nfc_write_enabled)) {
        menu.removeItem(R.id.write_tag);
    }

    // Locate MenuItem with ShareActionProvider
    MenuItem item = menu.findItem(R.id.share);

    // Fetch and store ShareActionProvider
    setShareActionProvider((ShareActionProvider) item.getActionProvider());

    return true;
}

From source file:bupt.tiantian.callrecorder.callrecorder.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    optionsMenu = menu;//  www . j  a  v  a  2s . com
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    SwitchCompat switchCompat = (SwitchCompat) menu.findItem(R.id.onswitch).getActionView()
            .findViewById(R.id.switch1);
    switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            AppPreferences.getInstance(MainActivity.this).setRecordingEnabled(isChecked);
        }
    });
    switchCompat.setChecked(AppPreferences.getInstance(MainActivity.this).isRecordingEnabled());
    return true;
}