SearchView setOnCloseListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SearchView setOnCloseListener method.

This code example shows how to use the following methods:setIconifiedByDefault, setOnCloseListener, setOnQueryTextListener
            MenuItem item = menu.add("Search");
            item.setIcon(android.R.drawable.ic_menu_search);
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
                    | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
            mSearchView = new MySearchView(getActivity());
            mSearchView.setOnQueryTextListener(this);
            mSearchView.setOnCloseListener(this);
            mSearchView.setIconifiedByDefault(true);
            item.setActionView(mSearchView);
        } 
 
        @Override public boolean onQueryTextChange(String newText) {
            // Called when the action bar search text has changed.  Since this 
            // is a simple array adapter, we can just have it do the filtering. 
            mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
            mAdapter.getFilter().filter(mCurFilter);
            return true; 
        } 
 
        @Override public boolean onQueryTextSubmit(String query) {
5
CodeRank

Related SearchView setOnCloseListener Questions & Answers:

setOnCloseListener Method Overview
Sets a listener to inform when the user closes the SearchView.
See Code Examples for other Android SearchView Methods: