我正在我的应用程序中使用工具栏。当我尝试使用工具栏时,应用程序崩溃了。
“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/