2015-07-11 52 views
0

我跟着this tutorial製作滑動的拉我的應用程序之後,我遇到了錯誤:的Android滑標籤錯誤

Unable to start activity ComponentInfo{com.cap2.macsanity.droidgency/com.cap2.macsanity.droidgency.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class

這是我的活動main.xml中

<LinearLayout 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" 
    android:orientation="vertical" 
    tools:context=".MainActivity"> 

    <include 
     android:id="@+id/tool_bar" 
     layout="@layout/tool_bar" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     /> 

    <com.cap2.macsanity.droidgency. 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/ColorPrimary"/> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent" 
     android:layout_weight="1"></android.support.v4.view.ViewPager> 

</LinearLayout> 

任何一個都可以幫我?提前致謝。

編輯2# 這是固定的,現在解決謝謝。

+0

你可以在這裏發佈你的xml嗎? – NilayDani

+0

sir/mam nilaydani我已經編輯了我的文章。 – Macsanity

回答

0

這裏,只是所需的軟件包的名稱以類定義正確的庫名,如果您按CTRL +點擊,比它會被重定向到您的類,並且如果它不是比你的庫名類名不存在。

如果你的圖書館名稱是com.cap2.macsanity.droidgency。和您的包名稱活動和您的類名稱是MainActivity,比您選擇的行將是

<com.cap2.macsanity.droidgency.Activity.MainActivity 
!------- 
!------ 
/> 

我希望這會爲你工作。這對我來說可以。

+0

是的,我忘了那條線,現在它的好和工作:)謝謝 – Macsanity

+1

任何時候歡迎您,如果它工作正常,請upvote或喜歡它。 –

0
<com.cap2.macsanity.droidgency. 

Here is the issue correct this with proper class name

+0

另一個錯誤sir @NilayDani「java.lang.RuntimeException:無法啓動活動ComponentInfo {com.cap2.macsanity.droidgency/com.cap2.macsanity.droidgency.MainActivity}:java.lang.IllegalStateException:該活動已經有一個動作由窗口裝飾提供。不要求Window.FEATURE_ACTION_BAR並在你的主題中設置windowActionBar爲false,以使用工具欄代替「 – Macsanity

+0

我修復了錯誤,先生,感謝您的幫助:) – Macsanity