Android – Actionbar’s Home up arrow is not showing when display options are set in XML

androidandroid-actionbar

I couldn't find anything over the web about my problem, so I figured I'd share it here.

My problem: I am working on a tablet app, and it has an ActionBar. Said ActionBar's display options were previously set in my Activities' onCreate through:

final ActionBar
    bar = getActionBar();
bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP|ActionBar.DISPLAY_SHOW_HOME|ActionBar.DISPLAY_USE_LOGO);

Everything was going on fine back then, an arrow was displayed on the home icon automatically to show to the user that he could navigate up.

Now, I'd like to set it through an XML style – that I already had for background, but just though about using for display options. Here's how I do it:

<!-- actionbar's style -->
<style name="Widget.myProject.Light.ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@drawable/bg_action_bar</item>
    <item name="android:displayOptions">homeAsUp|useLogo|showHome</item>
</style>

The problem with that new way of doing it is that the arrow on the home icon is not showing up on my Android 3.2 tablet. Whether I set the display options programmatically or not, as long as I set it in the XML, it fails to display it.

Has anyone ever faced this situation and somehow found a way to solve it?

Best Answer

For me works only this code:

ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);        
actionBar.setHomeButtonEnabled(true);
Related Topic