android.view.InflateException: Binary XML file line #22: Binary XML file line #22:


做项目时,犯了一个低级错误,好半天才找到,过程是这样:

错误提示如下:

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 code 
 View(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 ,解决!!!抓狂


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值