ActionbarSherlock SearchView not close in onCloseListener

133 views Asked by At

I have implemented onCloseListener of SearchView. I want to close SearchView Programmatically that i have done using following code. but its not working for me.

If i use searchView.setIconified(true); for closing searchView after updating data, run infinite times.

    searchView.setOnCloseListener(new SearchView.OnCloseListener() {

        @Override
        public boolean onClose() {
            // TODO Auto-generated method stub
            searchString = "";

            if (bindingProducts()) {
                 HIDE ERROR MSG 
                (findViewById(R.id.productIfNoAvailable)).setVisibility(View.GONE);
            } else {
                  SHOW ERROR MSG 
                (findViewById(R.id.productIfNoAvailable)).setVisibility(View.VISIBLE);
            }

            searchView.setIconified(true);

            return true;
        }
    });

How can i close after updating View?

Your help will be appreciated.

Thanks.

1

There are 1 answers

1
Joris On BEST ANSWER

If you let the onClose return true it means that you are consuming the close event. If you return false the system will close the SearchView for you.