java.lang.ClassCastException: android.view.ViewGroup$LayoutParams错误
2012-10-20 10:45
417 查看
原帖http://www.yinlans.com/layoutparams/
if(convertView==null){
imageview=new ImageView(context);
imageview.setLayoutParams(new GridView.LayoutParams(45,45));
imageview.setAdjustViewBounds(false);
imageview.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageview.setPadding(8, 8, 8, 8);
}else{
imageview=(ImageView) convertView;
}红色代码是我开始没写,出现了上面的错误。
大家今后看见这种错误就去查看代码LayoutParams,看有没有少写。
相关文章推荐
- java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.R
- java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.view.ViewGroup$MarginLayoutParams
- 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.L
- java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.L(转)
- 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.view.
- Caused by: java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams 错误
- 错误:java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
- java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.wid
- LayoutParams 类型转换异常:java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams
- java.lang.ClassCastException: android.widget.*Layout$LayoutParams
- android异常总结--java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast t
- java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.wid
- java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutPara
- java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.wid
- java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.widg
- Caused by: java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams
- 莫明的Caused by: java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams
- 开发问题及解决 java.lang.ClassCastException:android.widget.LinearLayout$LayoutParams