Android疯狂讲义中,基于回调的事件处理,报错Binary XML file line #8: Error inflating class org.crazyit.event.MyButton

菜鸟一枚,正在学习Android 开发,照着李刚的疯狂Android 讲义按部就班的一点点接触,里面的代码自己敲进去后总会或多或少有些错误,需要自己调试,今天分享一下最新遇到的。

在第三章,基于回调的事件监听器中,模拟运行时报错:Binary XML file line #8: Error inflating class org.crazyit.event.MyButton,表示使用回调按钮出错

查证之后是自己调用的包文件名不对,书上给出的代码是他默认的包文件名:

<<span style="color:#ff0000;">org.crazyit.event.</span>MyButton
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="单击我"
        />
而自己创建工程的包文件名是:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="<span style="color:#ff0000;">com.cuc604.chaptertheer</span>">
所以只需要把原代码中的包名改过来就可以正确执行了:
<<span style="background-color: rgb(255, 255, 255);"><span style="color:#00cccc;">com.cuc604.chaptertheer.MyButton</span></span>
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="单击我"
        />


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值