android.view.ViewGroup$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams
来源:互联网 发布:js所有方法 编辑:程序博客网 时间:2024/05/18 01:51
今天在实现动态改变布局的时候,报了个Error<android.view.ViewGroup$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams>
仔细去看了下代码,发现自己真的太粗心大意了,记下来,方便日后翻阅。
原代码:
ll_Pop_Params = ll_pop.getLayoutParams();
img_Product_Params = img_product_large.getLayoutParams();
ll_Pop_Params.width = (int) (width * 0.85);
ll_Pop_Params.height = (int) (width * 1.275);
ll_pop.setLayoutParams(ll_Pop_Params);
img_product_large.setLayoutParams(new ViewGroup.LayoutParams((int) (width * 0.85), (int) (width * 0.75)));
修改后:
img_Product_Params = img_product_large.getLayoutParams();
ll_Pop_Params.width = (int) (width * 0.85);
ll_Pop_Params.height = (int) (width * 1.275);
ll_pop.setLayoutParams(ll_Pop_Params);
img_product_large.setLayoutParams(new RelativeLayout.LayoutParams((int) (width * 0.85), (int) (width * 0.75)));
不能粗心不能粗心,要仔细!
0 0
- android.view.ViewGroup$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams
- ViewGroup$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams错误提示
- android.view.ViewGroup$LayoutParams cannot be cast to android.widget.TableRow$LayoutParams
- 解决 android.view.ViewGroup$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams
- 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.widget.R
- java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.
- Android异常:RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
- LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
- android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutPara
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParam
- java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutPara
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParam
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParam
- 安全的数据库部署自动化
- Fragment内部控件操作的E/AndroidRuntime(1778): java.lang.NullPointerException问题解决
- HDU 1166 敌兵布阵
- HDU 1754 I hate it
- HDU 4417 Super Mario
- android.view.ViewGroup$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams
- HDU 1540 Tunnel Warfare
- HDU 3308 LCIS
- Aoj 418 ACM 排名
- 在c/c++内镶汇编语句
- Aoj 560 取石子
- AOJ 435 带小数高精度
- AOJ 401 Fibonacci & GCD
- POJ 2049 Finding Nemo