Cómo ocultar la búsqueda del menú Android Studio de la actividad

// put below code in oncreatOptionMenu(); 
// the use  flag as global variable in your class 
// change its value as you need the call the function invalidateOptionsMenu()
// this function is call the oncreateOptionMenu()
MenuItem item = menu.findItem(R.id.menu_Done);

if (flag/condition)) {
  item.setVisible(false); // its a simple example
} else { 
   item.setVisible(true); 
}
Mohamed Boumlyk