SearchView setQuery, other customizations not possible?

Author: inmythCreated Sep 2, 2013Updated Dec 7, 2015

I picked the code from the demo SearchViews below and added a single line setQuery to searchView in onCreateOptionsMenu method. It didn't work. In fact I see that at least setIconified doesn't work either. Is this behavior expected from creating searchView on onCreateOptionsMenu method ? Because the only way I could make it work is by adding the modified searchView to ActionBar.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean isLight = SampleList.THEME == R.style.Theme_Sherlock_Light;
    final SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());            
   searchView.setQuery("test", false);

    menu.add("Search")
        .setIcon(isLight ? R.drawable.ic_search_inverse : R.drawable.abs__ic_search)
        .setActionView(searchView)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    return true;
}

Source: JakeWharton/ActionBarSherlock