Search code examples
androidactionbarsherlockslidingmenu

Show a custom button on ActionBarSherlock to show a Sliding menu


I'm developing an Android application that uses ActionBarSherlock with SlidingMenu.

Now, this is how I show the button to open the menu:

enter image description here

But don't want to show that < in left, and change its icon for a custom.

enter image description here

This is how I set up Sliding Menu:

private void setUpSlidingMenuAndActionBar()
{
    setBehindContentView(R.menu.menu);

    setSlidingActionBarEnabled(true);        

    slidingMenu = getSlidingMenu(); 
    slidingMenu.setMode(SlidingMenu.LEFT);
    slidingMenu.setSlidingEnabled(false);
    slidingMenu.setBehindOffset(100);

    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

How can I remove that < icon on the left and change the home button icon?

When I tap on that button I open the sliding menu.

UPDATE:

Following blackbelt answer, this is what I did:

styles.xml:

<style name="AppTheme.ActionBarStyle" parent="@style/Theme.Sherlock">
    <item name="android:homeAsUpIndicator">@drawable/but_menu</item>
    <item name="homeAsUpIndicator">@drawable/but_menu</item>
</style>

Manifest.xml:

<application
    [ ... ]
    android:theme="@style/AppTheme.ActionBarStyle" >

The result:

enter image description here

I can see the green Android!!! I don't want to see it!!


Solution

  • Use homeAsUpIndicator inside styles

     <item name="android:homeAsUpIndicator">@drawable/home_up_drawable</item>
     <item name="homeAsUpIndicator">@drawable/home_up_drawable</item>
    

    Mine looks like:

    <style name="AppTheme.ActionBarStyle" parent="@style/Widget.Sherlock.ActionBar.Solid">
        <item name="android:homeAsUpIndicator">@drawable/home_up_drawable</item>
        <item name="homeAsUpIndicator">@drawable/home_up_drawable</item>
        <item name="android:titleTextStyle">@style/AppTheme.TitleTextStyle</item>
        <item name="android:background">@drawable/actionbar_background</item>
        <item name="background">@drawable/actionbar_background</item>
        <item name="android:displayOptions">showHome|useLogo</item>
        <item name="displayOptions">showHome|useLogo</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="windowContentOverlay">@null</item>
    </style>