code: public void setOnQueryTextListener(@NonNull final SearchView.OnQueryTextListener listener) {
          if (searchView != null) {
              searchView.setOnQueryTextListener(listener);
          } else if (supportView != null) {
              supportView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {
                  @Override public boolean onQueryTextSubmit(String query) {
                      return listener.onQueryTextSubmit(query);
                  }
  
                  @Override public boolean onQueryTextChange(String newText) {
                      return listener.onQueryTextChange(newText);
                  }
              });
          } else {
              throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
          }
      }
docs: Sets a listener for user actions within the SearchView.
  
  @param listener the listener object that receives callbacks when the user performs
  actions in the SearchView such as clicking on buttons or typing a query.