android问题java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.wid

2025-06-22 11:08:29
推荐回答(4个)
回答1:

这个异常是类型转换异常,ImageButton不能转换成ToggleButton, 绝对布局时候控件应该是不能覆盖的把,你一移动就把ToggleButton覆盖了,感觉你要把ImageButton 转换成ToggleButton(当然,这是不能转换的),所以会报异常。

我只是给点提示,回答的对不对是另外说的啊

回答2:

findviewbyid 时候强制转换类型不对

回答3:

ImageButton 不能盖住 ToggleButton

回答4:

好像布局中俩个组件位置有冲突。。。