Not available

I create Optionmenu, for this I use the Android Android resource. But I canโ€™t access them, which Iโ€™m doing wrong. What do i need to change?

Here is 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 your help in advance!

+6
source share
3 answers

You are almost right, when accessing infrastructure resources, you need a prefix of the android: resource type, since you are using the android package Here. This means that it should not be

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

but

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

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


Also note that you cannot access some resources, as they are not publicly available, for example ic_menu_star , which you use here. You must copy them into your projects with the ability to create folders, which means that after that you should access them through the usual @drawable/ic_menu_star . See this question for reference.

+23
source

try:

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

instead:

 android:icon="@drawable/ic_menu_view" 
+1
source

Try the following:

 <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. Instead, you should use @ drawable /

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

Hope this helps ...

-2
source

Source: https://habr.com/ru/post/903097/


All Articles