1

I had my application using the ActionBarActivity, but I made the mistake of upgrading Android Studio with version 22. So now I'm trying to get the AppCompatActivity to work, but I am getting the error

Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.Toolbar

My Activity

@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>

My Activity layout xml

<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>
galath
  • 5,717
  • 10
  • 29
  • 41
reemul
  • 95
  • 1
  • 10

1 Answers1

0

I ended up deleting the layout for the app_bar and recreating it, then in the layout of the Activity I changed the id to something other than the layout file name. I also did a clean and a restart.

reemul
  • 95
  • 1
  • 10