4

The attribute in my activity is like below:

ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);

And the menu layout of my menuoption 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 click the search button and return,the icon of homeasup which I want to use it with navagation drawer would disappear.I do not know why.

Everything will get fine if I remove actionBar.setDisplayShowHomeEnabled(false). .

Marshal Chen
  • 1,985
  • 4
  • 24
  • 35
  • Did you try to (re)set the HomeAsUp indicator to true with a [listener](http://stackoverflow.com/a/10705138/2668136) on the SearchView? – Blo May 05 '14 at 08:25
  • @Fllo Yes,I try to set it in the setOnCloseListener,but there is nothing happened – Marshal Chen May 05 '14 at 08:52
  • 1
    On emulator or real device and specially what is the API tested? – Blo May 05 '14 at 08:55
  • Oh yes,it's on emulator,but the fact is if I choose a real device instead,the problem would appear like this http://stackoverflow.com/questions/17360477/actionbardrawertoggle-is-not-setting-drawer-indicator .Thank you very much – Marshal Chen May 05 '14 at 09:30
  • @MarshalChen did you solved it? – Navakanth Apr 30 '15 at 09:38

1 Answers1

-1

I have the same problem. My workaround was to use a transparent 1 pixel icon as my home icon so that I can remove the setDisplayShowHomeEnabled(false) method but still NOT have an icon since it is transparent.

user2395286
  • 457
  • 7
  • 18