2015-07-11 93 views
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> 

回答

0

我最終刪除佈局爲app_bar並重新創建它,然後在活動的佈局我換了ID比佈局文件名以外的東西。我也做了一個乾淨的和重新啓動。

相關問題