I need to show SearchView always expanded and one more button in ActionBar to give user quick access to search string in Search Activity.
I have this menu layout for my activity:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_search"
android:title="@string/action_search"
android:icon="@drawable/ic_action_search"
android:showAsAction="always"
android:actionViewClass="com.actionbarsherlock.widget.SearchView"/>
<item android:id="@+id/action_configure"
android:title="@string/action_configure"
android:icon="@android:drawable/ic_menu_preferences"
android:showAsAction="always" />
</menu>
And in Search activity class I configure ActionBar as follows:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.search, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView)menu.findItem(R.id.action_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false);
searchView.setSubmitButtonEnabled(false);
return true;
}
The problem is that if I do searchView.setIconifiedByDefault(false); I see this picture:
You can notice that there's no second menu item. Here, if I set android:showAsAction="always|collapseActionView", it becomes collapsed by default, but I can see second item now:
On the picture above I already pressed search icon
There are two problems that I can't figure out:
- How do I show always two elements: expanded search view and icon for configuration action?
- How do I get rid of this ugly second search icon?