Have you been banging your head over this action_search error? I have been too. The problem arose when I did everything right according to Official Android Guide but still this happened.
The guide says do this for adding action buttons in Action bar.
<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 overflow -->
<item android:id="@id/action_settings"
android:title="@string/action_settings"
android:showAsAction="never" />
</menu>
And I did exactly the same. Where is the problem then? I am a rookie learner but I will make my way. I finally realized that I do not have any image which I could use as icon named ic_action_search so, this is problem.
To get rid of this, you'd certainly have to add ic_action_search to drawable. I found a better way to do it.
Here are the steps:
Press Ctrl+N while you're in Eclipse. It will open the file Wizard.
Select Android > "Android Icon Set".
Select "Action Bar and Tab Icons".
Name the Icon appropriately. In my case, it was ic_action_search.
Click Next.
Clipart > 'Choose'
You'll be presented with icons window where in you can choose the icon which you want.
I needed the search icon, so, I selected that one.
Finish.
Now, you can see the error is gone!
Wow. So simple in Eclipse. I struggled for 3 days with this problem in Android Studio and ended up downloading commercial icons, which I have to manage myself.I wish we had such tool in Android Studio
ReplyDeleteJust to get the icons I downloaded Eclipse and followed your instructions - now I have a source where to get the icons
ReplyDelete