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.
If you let the
onClosereturn true it means that you are consuming the close event. If you return false the system will close theSearchViewfor you.