【发布时间】:2015-03-03 22:52:21
【问题描述】:
我正在关注 google Android Studio 第一个 android 应用教程。但是当我尝试向我的应用程序添加搜索栏时,我现在遇到了 3 个奇怪的错误。
我现在就在这里,我像教程一样添加了 XML 代码。
http://developer.android.com/training/basics/actionbar/adding-buttons.html
我得到的错误:
Error:(5, 23) No resource found that matches the given name (at 'icon' with value '@drawable/ic_action_search').
Error:(6, 24) No resource found that matches the given name (at 'title' with value '@string/action_search').
在 android:showAsAction="ifRoom" 我收到奇怪的错误:
Excecution failed for task ':app:procesDebugResources'.
这是我的 XML 代码:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"
android:showAsAction="ifRoom" />
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
</menu>
这段代码有什么问题?
感谢阅读/帮助!
【问题讨论】:
-
您的可绘制文件夹中有一个名为
ic_action_search的图标吗? -
文件夹中不仅有 ic_launcer.png:drawable-hdpi、drawable-mdpi、drawable-xhdpi 和 drawable-xxhdpi。正常的drawable文件夹是空的。
-
那你为什么期望找到它?
-
@Stefan : 你在使用支持库 Action Bar 吗?
-
@squonk 我跟着添加了这个库,但我认为我做错了什么?如果我添加了这个库,我在哪里可以找到?
标签: java android xml android-studio