自定义View时出现:"android.view.InflateException: Binary XML file line报错问题"

来源:互联网 发布:微信水果老虎机源码 编辑:程序博客网 时间:2024/06/05 07:35

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中
0 0
原创粉丝点击