Adding android drawable to menu XML stop app compiling
Asked Answered
C

1

1

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.

Churchy answered 29/9, 2012 at 23:17 Comment(1)
S
1

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

Spiers answered 29/9, 2012 at 23:22 Comment(3)
Sorry I don't understand, as its in the same directory that I got the other menu item names from, how come I need to do it in a different way, and what way would I do itChurchy
He means you can't use that image from the SDK, even though it's there. The easiest way to use non-public resources is to go to the SDK folder (android-sdk/platforms/android-nn/data/res) and copy them to your project. Then you could do the plain @drawable/refreshKith
Ok, thanks for your help, bit annoying that you can't use some of the icons and there all mixed together#Churchy

© 2022 - 2024 — McMap. All rights reserved.