1

アプリケーションで を使用していましたが、ActionBarActivityAndroid Studio をバージョン 22 にアップグレードするというミスを犯しましたAppCompatActivity

Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class 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();
}

私の 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>

私のActivityレイアウト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>
4

1 に答える 1

0

app_bar のレイアウトを削除して再作成した後、Activity のレイアウトで id をレイアウト ファイル名以外の名前に変更しました。また、クリーンアップと再起動を行いました。

于 2015-07-11T23:17:34.333 に答える