androidx.constraintlayout.widget.ConstraintLayout cannot be cast to android.widget.LinearLayout

编程入门 行业动态 更新时间:2024-10-12 05:44:40

androidx.constraintlayout.<a href=https://www.elefans.com/category/jswz/34/1759422.html style=widget.ConstraintLayout cannot be cast to android.widget.LinearLayout"/>

androidx.constraintlayout.widget.ConstraintLayout cannot be cast to android.widget.LinearLayout

卡了半天。哎。写个日志记录一下。长个经验!

我的最终目的是:点击一个item,去启动一个Activity页面。这个页面,我给了一个id,并且第一级是线性布局LinearLayout。并且申明了变量,为

LinearLayout  mLinearLayout

随后我写了点击item的监听事件。启动APP就开始报错:

java.lang.ClassCastException: androidx.constraintlayout.widget.ConstraintLayout cannot be cast to android.widget.LinearLayout

卡了我半天,终于找到问题了。原来,在layout里,把第一级LinearLayout写成了:

<androidx.xxxxxxxxxxxxxxxxxxxxxxxxxx

改过来,就好了!

也就是第一级布局视图必须是LinearLayout。如果是其它布局,就会报错。

更多推荐

androidx.constraintlayout.widget.ConstraintLayout cannot be cast to android.widg

本文发布于:2024-03-13 19:55:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1734706.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:widget   constraintlayout   androidx   ConstraintLayout   LinearLayout

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!