The attribute in my activity is as follows:
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
And the menu layout of my menu is below:
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
com.xxx:showAsAction="ifRoom|collapseActionView"
com.xxx:actionViewClass="android.support.v7.widget.SearchView"
android:title="weibo"/>
But if I press the search button and return, the homeasup icon that I want to use with the manure box will disappear. I do not know why.
Everything will be fine if I remove actionBar.setDisplayShowHomeEnabled(false). .
source
share