报错信息如下:
Process: com.example.lxh1205509119.xiaoprinter, PID: 27636
android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.example.lxh1205509119.xiaoprinter.GeneralItemLayout
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.example.lxh1205509119.xiaoprinter.GeneralItemLayout
Caused by: java.lang.reflect.InvocationTargetException
由该提示可以看出问题出在GeneralItemLayout的xml布局文件里,接着往下看:
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: You must supply a layout_width attribute.
Caused by: java.lang.UnsupportedOperationException: Binary XML file line #0: You must supply a layout_width attribute.
由上面的错误信息可知由于在xml文件中缺少了layout_width属性值,打开GeneralItemLayout对应的布局文件,搜索layout_width字段,检查每隔控件是否都有layout_width属性,最后发现在TextView控件中缺少该属性,虽然该处设置了width的权重值,但layout_width还是不能缺,设置成android:layout_width="0dp"之后问题解决。