1
我不得不使用ActionBarActivity
我的應用程序,但我做了升級的Android工作室22版本,所以現在我試圖讓AppCompatActivity
工作的錯誤,但我得到的錯誤錯誤充氣類的Android
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>