Reputation: 6839
I am beginning android development and I am having problems making an action bar. Basically I am following some code form online and I am getting an error saying I do not have an icon:
error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_menu_search').
I did some research and thought my problem was I did not have all the extras downloaded from the android SDK. But after downloading all the extras it didnt work. I know I could just find the icon and download it, but I do not want to have to download all the icons individually, therefore I think I am missing something. My xml file I am getting the error with looks like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
<item android:id="@+id/menu_search"
android:title="@string/menu_search"
android:icon="@drawable/ic_menu_search"
android:showAsAction="ifRoom|collapseActionView"
android:actionViewClass="android.widget.SearchView" />
</menu>
this is under menu>main.xml
Upvotes: 2
Views: 587
Reputation: 157437
If you want to use the android icon, you should add the android
prefix after @
. Change
@drawable/ic_menu_search
in
@android:drawable/ic_menu_search
@drawable
looks inside the res/drawable*
folder of your app. If you want to access to the android resources. strings/drawable/id you have to put the android
prefix after the @
. with that prefix you will access to the android.R class not to your.R class
Upvotes: 4