close searchview android java

Java
if (!searchView.isIconified()) {
  searchView.setIconified(true);
}
Source

Also in Java: