Android 自定义View java.lang.RuntimeException: Unable to start activity ComponentInfo

来源:互联网 发布:淘宝vr购物 编辑:程序博客网 时间:2024/06/14 12:02

在Android 4.1.2环境下,自定义了一个View, 运行时出现

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.matrixtest/com.example.matrixtest.MainActivity}: android.view.InflateException: Binary XML file line #26: Error inflating class MatrixImageView


搜寻半天,后来发现是我自定义View的问题

自定义的View需要重写所有的构造方法  即:

<span style="white-space:pre"></span>public MatrixImageView(Context context) {super(context);// TODO Auto-generated constructor stub}public MatrixImageView(Context context, AttributeSet attri) {super(context, attri);// TODO Auto-generated constructor stub}public MatrixImageView(Context context, AttributeSet attri, int defStyle) {super(context, attri, defStyle);// TODO Auto-generated constructor stub}


0 1