Code example for SearchView

Methods: clearFocus, getWindowToken

0
        // more easily browse the list of results. 
        if (mSearchView != null) {
            InputMethodManager imm = (InputMethodManager) mContext.getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            if (imm != null) {
                imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0);
            } 
            mSearchView.clearFocus();
        } 
        return true; 
    } 
 
    @Override 
    public boolean onClose() { 
        setSearchMode(false); 
        return false; 
    } 
 
    public void onSaveInstanceState(Bundle outState) {
        outState.putBoolean(EXTRA_KEY_SEARCH_MODE, mSearchMode);
        outState.putString(EXTRA_KEY_QUERY, mQueryString);