Android drawable ic_menu_star not working?
I'm designing a menu in XML:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:icon="@android:drawable/ic_menu_preferences" android:title="@string/menu_preferences" android:id="@+id/menu_preferences"/>
<item android:id="@+id/menu_bookmarks" android:title="@string/menu_bookmarks" android:icon="@android:drawable/ic_menu_star"></item>
<item android:title="@string/menu_history" android:id="@+id/menu_history" android:icon="@a开发者_StackOverflow中文版ndroid:drawable/ic_menu_recent_history"></item>
</menu>
When I try to use the android drawbale ic_menu_star my eclipse throws an error:
[2011-07-06 00:52:28 - Testapp] W/ResourceType( 1852): Bad XML block: header size 51 or total size 3342532 is larger than data size 0
[2011-07-06 00:52:28 - Testapp] C:\eclipseprojects\Testapp\res\menu\search_menu.xml:4: error: Error: Resource is not public. (at 'icon' with value '@android:drawable/ic_menu_star').
I've checked the android resources in my project and it is in there. I'm building my project on the android 2.1 framework. Is this a bug?
Some drawables in the Android package aren't declared as public, and can't be referenced in this way.
The only way to use this drawable is to copy it into your own drawable directory and reference it there.
Edit: Google have since added a pack of action bar icons to the Android Developer site.
Best way to find the default ones in Android Studio and right click on /drawable folder -> New -> Image Asset and follow the steps, most likely the asset is in "ClipArt"
精彩评论