做项目时,犯了一个低级错误,好半天才找到,过程是这样:
错误提示如下:
android.view.InflateException: Binary XML file line #22: Binary XML file line #22:
看到错误第一反应,Soeasy!
解决方法无外乎
1.自定义View必须使用完整路径名。
2.定义View,必须派生实现基类View的三个构造函数 。
View(Context context) //Simple constructor to use when creating a view from codeView(Context context, AttributeSet attrs) //Constructor that is called when inflating a view from XML
View(Context context, AttributeSet attrs, int defStyle) //Perform inflation from XML and apply a class-specific base style
3.Rebuild project
4.资源文件引用错误。
一上来就找自定义view的错误,然并卵,还费半天时间,后来仔细看了一眼错误,如图!
想实现button的点击效果,就引用了selector
android:background="@drawable/btbg"
而selector 写成这样
不得不说,真的很蠢!
color改成drawable ,解决!!!