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:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.SignSearchActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Log.d(TAG, "onCreateOptionsMenu()" + this.hashCode());
    super.onCreateOptionsMenu(menu);
    final MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_sign_browser_search, menu);
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    final MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    return true;/*from   ww  w .j  ava  2  s  . c o  m*/
}

From source file:ca.zadrox.dota2esportticker.ui.MatchActivity.java

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

    MenuItem notificationItem = menu.findItem(R.id.menu_debug_notify);
    if (notificationItem != null) {
        notificationItem.setVisible(BuildConfig.DEBUG);
    }//w w w  . ja  v a2 s . c  o m

    MenuItem matchMenuItem = menu.findItem(R.id.menu_debug_view_live_match);
    if (matchMenuItem != null) {
        matchMenuItem.setVisible(BuildConfig.DEBUG);
    }

    return true;
}

From source file:ch.dbrgn.android.simplerepost.activities.RepostActivity.java

/*** Menu ***/

@Override//w  ww.j  av a  2s . co  m
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_repost, menu);

    // Get spinner
    MenuItem item = menu.findItem(R.id.spinner_style);
    Spinner spinner = (Spinner) MenuItemCompat.getActionView(item);

    // Prepare data
    String[] spinnerArray = new String[Config.REPOST_STYLES.size()];
    Iterator<String> styleIterator = Config.REPOST_STYLES.keySet().iterator();
    for (int i = 0; i < Config.REPOST_STYLES.size(); i++) {
        spinnerArray[i] = styleIterator.next();
    }

    // Set adapter
    ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item,
            spinnerArray);
    spinner.setAdapter(adapter);

    // Handle clicks
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // Fix text color
            CheckedTextView textView = (CheckedTextView) view;
            textView.setTextColor(Color.WHITE);

            // Update watermark
            int style = (int) Config.REPOST_STYLES.values().toArray()[position];
            updateWatermark(style);
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });

    return true;
}

From source file:it.gulch.linuxday.android.fragments.EventDetailsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.event, menu);
    menu.findItem(R.id.share).setIntent(getShareChooserIntent());
    bookmarkMenuItem = menu.findItem(R.id.bookmark);
    updateOptionsMenu();/*ww  w.  j  a  va 2s  .  co m*/
}

From source file:com.scigames.slidegame.Registration1UserNameActivity.java

/**
 * Called right before your activity's option menu is displayed.
 *///ww w.  j  a  va  2 s. c  o  m
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    // Before showing the menu, we need to decide whether the clear
    // item is enabled depending on whether there is text to clear.
    menu.findItem(CLEAR_ID).setVisible(firstName.getText().length() > 0);
    menu.findItem(CLEAR_ID).setVisible(lastName.getText().length() > 0);
    //menu.findItem(CLEAR_ID).setVisible(password.getText().length() > 0);

    return true;
}

From source file:com.pixplicity.castdemo.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat
            .getActionProvider(mediaRouteMenuItem);
    // Set the MediaRouteActionProvider selector for device discovery.
    mediaRouteActionProvider.setRouteSelector(CastProxy.getMediaRouteSelector());
    return true;/*w  w  w .  j  a v a2s .c o  m*/
}

From source file:de.Maxr1998.xposed.maxlock.ui.settings.appslist.AppsListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.applist_menu, menu);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.toolbar_search));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override/*ww w  .ja  v  a  2s .c  om*/
        public boolean onQueryTextSubmit(String s) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            mAdapter.getFilter().filter(s);
            return true;
        }
    });
}

From source file:asu.edu.msse.gpeddabu.moviedescriptions.AddMovie.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.movie_search_menu, menu);
    // setup the search in action bar
    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView = (android.widget.SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(this);
    return true;/*ww w. j a va  2s .  c  o m*/
}

From source file:net.eledge.android.europeana.gui.activity.SearchActivity.java

@SuppressWarnings("ConstantConditions")
@Override//w  w  w. j  a v a2 s  . c o  m
public boolean onPrepareOptionsMenu(Menu menu) {
    if (mDrawerLayout != null) {
        boolean drawerOpen = mDrawerLayout.isDrawerOpen(mFacetsList);
        menu.findItem(R.id.action_search).setVisible(!drawerOpen);
        menu.findItem(R.id.action_share).setVisible(!drawerOpen);
    }
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.github.chenxiaolong.dualbootpatcher.MainActivity.java

public void showReboot(boolean visible) {
    Menu menu = mDrawerView.getMenu();
    MenuItem item = menu.findItem(R.id.nav_reboot);
    if (item != null) {
        item.setVisible(visible);//from   w ww .ja v a 2 s  .  com
    }
}