Question

I'm creating a Optionsmenu, for that I use the Android Icon-Resource. But I can't access them, what am I doing wrong. What do I need to change?

Here's the Code of my menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@+id/Videos"
          android:icon="@android/drawable/ic_menu_view"
          android:title="Videos" />

    <item android:id="@+id/Bio"
          android:icon="@android/drawable/ic_menu_friendlist"
          android:title="Biographie" />

    <item android:id="@+id/Support"
          android:icon="@android/drawable/ic_menu_star"
          android:title="Support" />

</menu>

thank you for the help in advance!

Was it helpful?

Solution

You are almost correct, when accessing framework resources you have to prefix the resource type with android: since you are using the android package here. Which means it should not be

android:icon="@android/drawable/ic_menu_view"

but

android:icon="@android:drawable/ic_menu_view"

instead for example (note the colon between android and drawable instead of a forward slash).


Also note that you can't access some resources, since they are not public, such as the ic_menu_star you are using here. You have to copy them to your projects drawable folders, which means you have to access them via a normal @drawable/ic_menu_star after doing that. See this question for reference.

OTHER TIPS

try :

android:icon="@android:drawable/ic_menu_view"

instead of :

android:icon="@drawable/ic_menu_view"

Try this:

<item android:id="@+id/Videos"
      android:icon="@drawable/ic_menu_view"
      android:title="Videos" />

<item android:id="@+id/Bio"
      android:icon="@drawable/ic_menu_friendlist"
      android:title="Biographie" />

<item android:id="@+id/Support"
      android:icon="@drawable/ic_menu_star"
      android:title="Support" />

I think @android/drawable/ is incorrect. You should use instead @drawable/

You can see it: http://developer.android.com/guide/topics/ui/menus.html

Hope this helps...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top