Im using an action bar and adding a searchView to it. I have implemented the searchView.onCLoseListener but this does not seem to be getting invoked. Any suggestions ?
My code looks something like this :
SearchView searchView = new SearchView(getContext());
searchView.setOnCloseListener(new OnCloseListener() {
public boolean onClose() {
searchView.setVisibility(SearchView.GONE);
// Do Something
return true;
}
});
Ok. i got the mistake. We cant add a searchCommand and do
setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW)
Doing this would remove the searchText if any and hence we cant do a onClose().