【问题标题】:Use Icons from Sherlock Actionbar library使用 Sherlock Actionbar 库中的图标
【发布时间】:2013-09-10 20:08:40
【问题描述】:

我正在尝试在我的菜单 XML-File 中使用 Sherlock 操作栏的图标,但我无法找出正确的命名空间。

我尝试了 com.sherlock 和 com.sherlock.R,但似乎没有任何效果。我也找不到这方面的文档!

这就是我尝试过的:

<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>

但这只是失败并显示无法找到图标的错误消息。

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

任何想法如何获得正确的命名空间?

【问题讨论】:

    标签: android xml actionbarsherlock


    【解决方案1】:

    您无需放置命名空间。使用下面的代码

     <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>
    

    【讨论】:

    • 那行不通。找不到 action_refresh(不在我的项目中,但在 actionbar sherlock 项目中)。
    • @schlingel 使用@drawable/abs__ic_search 查看abc的res/drawable-hdpi文件夹来探索图标名称
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多