自定義View時出現:"android.view.InflateException: Binary XML file line報錯問題"

Android.View.InflateException: Binary XML File Line #異常的解決


可能兩種原因引起:

原因一:
   必須實現三個構造函數
    public GalleryFlow(Context context) {
            super(context);
    }

    public GalleryFlow(Context context, AttributeSet attrs) {
            super(context, attrs);
    }

    public GalleryFlow(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
    }
原因二:
   或者XML中包錯!
   <com.yourpackege.yourLayout
          android:id="@+id/name"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:background="@color/transparent"/>
   中yourLayout這個類不在com.yourpackege中
發佈了22 篇原創文章 · 獲贊 4 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章