Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中膨胀类时出错_Android_Toolbar_Inflate Exception_Appcompatactivity - Fatal编程技术网

在Android中膨胀类时出错

在Android中膨胀类时出错,android,toolbar,inflate-exception,appcompatactivity,Android,Toolbar,Inflate Exception,Appcompatactivity,我的应用程序使用了ActionBarActivity,但我犯了一个错误,将Android Studio升级为22版。因此,现在我试图让AppCompatActivity正常工作,但我遇到了错误 原因:android.view.InflateException:二进制XML文件行#2:对类android.support.v7.widget.Toolbar进行膨胀时出错 我的活动 @Override protected void onCreate(Bundle savedInstanceState

我的应用程序使用了
ActionBarActivity
,但我犯了一个错误,将Android Studio升级为22版。因此,现在我试图让
AppCompatActivity
正常工作,但我遇到了错误

原因:android.view.InflateException:二进制XML文件行#2:对类android.support.v7.widget.Toolbar进行膨胀时出错
我的活动

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

    toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    getFragmentManager().beginTransaction()
            .replace(R.id.content_frame, new UserPrefsFragment())
                    .commit();
}
My 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/grey">


</android.support.v7.widget.Toolbar>
<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="com.panicsystems.reemul.legalpanic.UserPrefsActivity">

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

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/app_bar"/>

</RelativeLayout>

最后,我删除了app_栏的布局并重新创建了它,然后在活动的布局中,我将id更改为布局文件名以外的内容。我还进行了清理和重新启动。

我最终删除了应用程序栏的布局并重新创建了它,然后在活动的布局中,我将id更改为布局文件名以外的内容。我还做了一次清理和重启