title: Where to Auto-Collapse ActionBar SearchView
body: <p>When a user submits a app wide search in the Search Widget in the <code>ActionBar</code>, I want it to auto collapse after submit.  Submit basically opens up the <code>SearchableActivity</code>.  Currently, if they close the search results activity (<code>SearchableActivity</code>), the Search Widget is still open.  I just want it closed; and with no text.</p>
  
  <p>From reading around, I seem to think that the answer is this</p>
  
  <pre><code>`searchView.onActionViewCollapsed() ;' 
  </code></pre>
  
  <p>however, I am not sure where to put it?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater inflater = getSupportMenuInflater();
      inflater.inflate(R.menu.menu, menu);
      MenuItem searchItem = menu.findItem(R.id.menu_search);
      SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  
  if (Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.HONEYCOMB) {
      SearchView searchView = (SearchView) searchItem.getActionView();
      searchView.setSearchableInfo(searchManager
              .getSearchableInfo(getComponentName()));
      searchView.setIconifiedByDefault(true);
  
  } else if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
      setupNewSearchView(searchItem, searchManager);
  
  
  
  }
  
  return true;
  }
  
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private void setupNewSearchView(final MenuItem searchItem,
          SearchManager searchManager) {
      android.widget.SearchView searchView = (android.widget.SearchView) searchItem
              .getActionView();
      searchView.setSearchableInfo(searchManager
              .getSearchableInfo(getComponentName()));
      searchView.setIconifiedByDefault(true);
  }
  
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
  
      MenuItem About = menu.findItem(R.id.About);
      MenuItem Login = menu.findItem(R.id.Login);
      MenuItem Logout = menu.findItem(R.id.Logout);
      MenuItem Settings = menu.findItem(R.id.Settings);
      MenuItem Search = menu.findItem(R.id.menu_search);
      MenuItem Add = menu.findItem(R.id.Add);
  
      Add.setVisible(false);
  
      if (LoggedStatus == true) {
          // show the log out option
          Logout.setVisible(true);
          Login.setVisible(false);
          Settings.setVisible(true);
      } else {
          // show the log in option
          Logout.setVisible(false);
          Login.setVisible(true);
          Settings.setVisible(false);
      }
  
      About.setVisible(true);
  
      return true;
  }
  </code></pre>
  
  <p>Note, I am using <code>SherlockActionBar</code>.</p>