I add a search item to ActionBar as follows:
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.menu_action_search) .getActionView(); if (null != searchView) { searchView.setSearchableInfo(searchManager .getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(true); }
I put the handler - everything works fine here (details can be found here ).
But further in the code (in another method), I need to access this input line in order to put my value there ... I can not figure out how to do this?
upd: You can make a field inside the SearchView searchView
class and using the field, manage the search text from any searchView.setQuery("", false);
method searchView.setQuery("", false);
.
But, I would like to find a way to access SearchView without creating a field.