我是靠谱客的博主 炙热美女,这篇文章主要介绍java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.,现在分享给大家,希望可以做个参考。
java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
报错原因:
ImageView image =(ImageView) findViewById(R.id.imageView1);
image.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
解决方法:
ImageView image =(ImageView) findViewById(R.id.imageView1);
image.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
小结:
遇到问题时,解决思路有哪些,强化下,第一理清问题环境和背景,如查看如上错误提示,马上就可以定位问题,快速解决。第二、三、四,
其实它不算是问题。为了强化这种思路,在此记录下。
最后
以上就是炙热美女最近收集整理的关于java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.的全部内容,更多相关java.lang.ClassCastException:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复