2

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.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437

1 Answers1

2

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.

Joris
  • 1,437
  • 1
  • 15
  • 22