I'm using Actionbar Sherlock. The activity be shown on startup should start in a "search mode" to start searching immediately. For doing so I use the following code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
//collapse search
MenuItem searchItem = menu.add(Menu.NONE, R.string.inlineSearch, Menu.NONE, getString(R.string.inlineSearch)).setIcon(R.drawable.menu_search);
searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
searchView = new SearchView(this);
searchItem.setActionView(new SearchView(this));
searchItem.expandActionView();
return true;
}
The SearchView is the View provided by Android / Actionbar Sherlock.
The problem I'm facing with that is that no matter what I do, the item is never expanded on startup. I tried calling the expandActionView method after startup by using another actionbar item, nothing changed. I implemented my own View implementing CollapsibleActionView, but the methods onActionViewExpanded() and onActionViewCollapsed() never get called.
But if I click the collapsed button of the SearchView, the view expands as expected.
Does anyone know what I'm doing wrong? Thanks for your help!