I am using Actionbar Sherlock. Startup activity must begin in "search mode" in order to start the search immediately. For this, I use the following code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
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;
}
SearchView is a view provided by Android / Actionbar Sherlock.
The problem I am facing is that no matter what I do, the element never expands at startup. I tried calling the expandActionView method after starting using another element of the action bar, nothing has changed. I implemented my own View that implements CollapsibleActionView, but the onActionViewExpanded () and onActionViewCollapsed () methods are never called.
But if I click the minimize button in SearchView, the view expands as expected.
- , ? !