android - 错误: No resource identifier found for attribute 'popupTheme' in package “com.example…”

标签 android compiler-errors attributes resources identifier

有很多与此类似的问题,但是我没有具体针对我的代码。他们都没有为此工作。

我正在尝试添加一个工具栏,显示here

但这对我不起作用,因为它向我显示了错误
No resource identifier found for attribute 'popupTheme' in package "com.example...
我的代码是这样的:

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/LinearLayoutMain"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<android.support.v7.widget.Toolbar
    android:id="@+id/my_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</RelativeLayout>

我还添加了appcompatcardview库,但是仍然遇到相同的错误。

有人知道答案吗?请回复。

最佳答案

在style.xml中定义以下样式

 <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

更改
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"  


    app:popupTheme="@style/AppTheme.PopupOverlay"

希望对您有帮助。

关于android - 错误: No resource identifier found for attribute 'popupTheme' in package “com.example…” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39688359/

相关文章:

javascript - 将 JSON 转换为放入 Sdcard 的 CSV 文件

jquery - 编写更高效的属性选择器函数

android - 多个dex文件定义Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat

android - PubNub 推送消息不起作用

java - 为什么我收到错误: cannot find symbol for JComponent?

c++ - 引用的无效初始化是什么意思?

macos - 在Xcode中使用FreeImage

python - 如何解决 AttributeError :'list' object has no attribute 'astype' ?

java - 如何检查未设置的对象是否具有属性

android - AsyncTask - 将 postExecute 中的字符串返回给 Activity,它在不阻塞 UI 线程的情况下启动异步任务