Search code examples
androidxmlactionbarsherlock

Use Icons from Sherlock Actionbar library


I'm trying to use the Icons of the Sherlock Actionbar in my menu XML-File but I can't figure the right namespace out.

I tried com.sherlock and com.sherlock.R but nothing seemed to work. I couldn't find documentation on that either!

That's what I tried:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:sherlock="http://schemas.android.com/apk/res/com.actionbarsherlock.R" >

<item 
    android:id="@+id/action_refresh"
    android:orderInCategory="99"
    android:showAsAction="ifRoom"
    android:icon="@sherlock:drawable/action_refresh"
    android:title="@string/action_refresh"
    />
</menu>

But that just fails with an error message that the icon couldn' be found.

Error: No resource found that matches the given name (at 'icon' with value '@sherlock:drawable/action_refresh')

Any ideas how to get the correct namespace?


Solution

  • you no need to put the namespace. use the below code

     <menu xmlns:android="http://schemas.android.com/apk/res/android" >
    
    <item 
        android:id="@+id/action_refresh"
        android:orderInCategory="99"
        android:showAsAction="ifRoom"
        android:icon="@drawable/action_refresh"
        android:title="@string/action_refresh"
        />
    </menu>