I\'m trying to clear and close SearchView after entering a value. I found a solution but it closes the search and won\'t perform any action if I try to search again.
In menu_main.xml add :
and in onCreateOptionsMenu
final MenuItem miSearch = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) miSearch.getActionView();
searchView.setQueryHint("Searh For");
searchView.setOnQueryTextListener(newSearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Toast.makeText(context,query, Toast.LENGTH_LONG).show();
// Here Put Your Code.
//searchView.onActionViewCollapsed();
miSearch.collapseActionView();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});