码迷,mamicode.com
首页 > 移动开发 > 详细

java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.L(转)

时间:2014-08-19 14:27:15      阅读:363      评论:0      收藏:0      [点我收藏+]

标签:android   java   os   io   for   ar   art   问题   

09-09 10:19:59.979: E/AndroidRuntime(2767): FATAL EXCEPTION: main
09-09 10:19:59.979: E/AndroidRuntime(2767): java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.widget.LinearLayout.measureVertical(LinearLayout.java:634)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.view.View.measure(View.java:12758)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.view.View.measure(View.java:12758)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.view.View.measure(View.java:12758)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
09-09 10:19:59.979: E/AndroidRuntime(2767): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2092)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.view.View.measure(View.java:12758)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1064)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2445)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.os.Handler.dispatchMessage(Handler.java:99)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.os.Looper.loop(Looper.java:137)
09-09 10:19:59.979: E/AndroidRuntime(2767): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-09 10:19:59.979: E/AndroidRuntime(2767): at java.lang.reflect.Method.invokeNative(Native Method)
09-09 10:19:59.979: E/AndroidRuntime(2767): at java.lang.reflect.Method.invoke(Method.java:511)
09-09 10:19:59.979: E/AndroidRuntime(2767): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
09-09 10:19:59.979: E/AndroidRuntime(2767): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
09-09 10:19:59.979: E/AndroidRuntime(2767): at dalvik.system.NativeStart.main(Native Method)


报错原因:
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.L(转),布布扣,bubuko.com

java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.L(转)

标签:android   java   os   io   for   ar   art   问题   

原文地址:http://www.cnblogs.com/dongweiq/p/3921879.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!