I was trying to run the following code from the android studio guide:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Search, should appear as action button -->
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"
android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:showAsAction="never" />
However, for the following code:
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"
It says:
Cannot resolve symbol '@string/action_search' less... (Ctrl+F1)
Validates resource references inside Android XML files
And that no resource matches the given name.
I am not sure how to make of it. I have googled extensively and these are possible solutions?
I have tried:
If someone could shed some light on this situation I would be very grateful! I have tried doing my own research/ googling/ experimenting but it has come to no avail.
You need to create the string value for your action_search reference.
<resources>
<string name="app_name">My Application</string>
<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>
<string name="action_settings">Settings</string>
<string name="action_search">Search</string>
<string name="title_activity_main">MainActivity</string>
<string name="title_activity_display_message">My Message</string>
</resources>
To fix your empty reference for your drawables you have to drop an image with the name of your reference like ic_action_search.png in your drawable folder.