android - java.lang.NoSuchFieldError : android. support.v7.appcompat.R$styleable.ActionBarWindow

标签 android android-appcompat

我正在我的应用程序中使用工具栏。当我尝试使用工具栏时,应用程序崩溃了。

“java.lang.NoSuchFieldError: android.support.v7.appcompat.R$styleable.ActionBarWindow "

我查看了 stackoverflow 的答案,但没有一个能解决我的问题。

这是我的代码:

app_bar.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:background="@color/green_background_color">

</android.support.v7.widget.Toolbar>

Activity 主题:

<style name="NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    </style>

list 声明:

<activity
            android:name="in.chabu.activities.SignUpActivity"
            android:label="@string/title_activity_sign_up"
            android:theme="@style/NoActionBar">
        </activity>

布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="in.chabu.activities.SignUpActivity" >

    <include
        android:id="@+id/tool_bar"
        layout="@layout/app_bar" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/tool_bar"
        android:text="@string/hello_world" />

</RelativeLayout>

Activity :

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_up);

        Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
        setSupportActionBar(toolbar);

    }

我正在使用 Eclipse IDE

最佳答案

修改你的样式如下:

<style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat.Light">
        <item name="android:windowNoTitle">true</item>
  </style>

关于android - java.lang.NoSuchFieldError : android. support.v7.appcompat.R$styleable.ActionBarWindow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29443159/

相关文章:

Android 选项菜单未在 API 2.x.x 上显示

Android 动画 - 翻转

android - 在安卓中寻找磁铁

java - NavigationDrawerFragment 不适用于 AppCompat 工具栏

android - 文本选择句柄似乎没有改变

android - 增加 SwitchCompat 的轨道长度

android - 解析不订阅的 LiveQuery - Android (Kotlin)

android - Session 过期后重新认证

android - Qt QML - 处理导航按钮?

android - CardView 在底部插入暗线