Adding android drawable to menu XML stop app compiling

血红的双手。 提交于 2020-01-15 12:08:17

问题


I am working on an android project and have an XML file for the action bar menu, its been working fine, but I now need to add an extra item with an icon, but it this displays an error in the eclipse tab and the console output. If I remove the icon field, then its fine, but if I add the icon, then I get the error.

Below is the XML that contains the menu item. I've included one item that previously worked and the new item that isn't working

<item android:id="@+id/mnu_search"
        android:title="Search"
        android:icon="@android:drawable/ic_menu_search"
        android:showAsAction="always">
    </item>
    <item android:id="@+id/mnu_sync"
        android:title="Sync"
        android:icon="@android:drawable/ic_menu_refresh"
        android:showAsAction="always">
    </item>

The sync menu item is the one that isn't working, the search item is working fine.

The error in the errors tab in eclipse says

Unparsed aapt error(s)! Check the console for output

Below is the console output

W/ResourceType( 9156): Bad XML block: header size 305 or total size 0 is larger than data size 0
C:\Users\Chris\workspace\AndroidPasswordManager\res\menu\main_menu.xml:13: error: Error: Resource is not public. (at 'icon' with value '@android:drawable/ic_menu_refresh').
W/ResourceType( 8896): Bad XML block: header size 300 or total size 0 is larger than data size 0
C:\Users\Chris\workspace\AndroidPasswordManager\res\menu\main_menu.xml:13: error: Error: Resource is not public. (at 'icon' with value '@android:drawable/ic_menu_refresh').
W/ResourceType( 8984): Bad XML block: header size 303 or total size 0 is larger than data size 0
C:\Users\Chris\workspace\AndroidPasswordManager\res\menu\main_menu.xml:13: error: Error: Resource is not public. (at 'icon' with value '@android:drawable/ic_menu_refresh').

I have no idea what could be wrong. I've check in the android sdk directory for the images and it definetely exists, I'm using api level 15.

Thanks for any help you can provide.


回答1:


The resource you are trying to use not public. It is used by android internally. Use your app drawable reference.



来源:https://stackoverflow.com/questions/12657351/adding-android-drawable-to-menu-xml-stop-app-compiling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!