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(转)的更多相关文章

  1. 解决 android.view.ViewGroup$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams

    错误日志1: 06-13 10:55:50.410: E/KVLog(1129): Error info:java.lang.ClassCastException: android.widget.Li ...

  2. java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.ProgressBar$SavedState

    java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.Progress ...

  3. Java-Spring:java.lang.ClassCastException: com.sun.proxy.$Proxy* cannot be cast to***问题解决方案

    java.lang.ClassCastException: com.sun.proxy.$Proxy* cannot be cast to***问题解决方案 临床表现: 病例: 定义代理类: @Tra ...

  4. java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext问题原因及解决方法

    一.错误信息 java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logb ...

  5. java.lang.ClassCastException: com.sun.proxy.$Proxy32 cannot be cast to com.bkc.bpmp.core.cache.MemcachedManager

    java.lang.ClassCastException: com.sun.proxy.$Proxy32 cannot be cast to com.bkc.bpmp.core.cache.Memca ...

  6. 关于利用动态代理手写数据库连接池的异常 java.lang.ClassCastException: com.sun.proxy.$Proxy0 cannot be cast to java.sql.Connection

    代码如下: final Connection conn=pool.remove(0); //利用动态代理改造close方法 Connection proxy= (Connection) Proxy.n ...

  7. java.lang.ClassCastException: com.sun.proxy.$Proxy2 cannot be cast to...异常

    异常: Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy2 cannot ...

  8. WebLogic部署报java.lang.ClassCastException: weblogic.xml.jaxp.RegistrySAXParserFactory cannot be cast to javax.xml.parsers.SAXParserFactory

    今天在部署WebLogic项目时,报了java.lang.ClassCastException: weblogic.xml.jaxp.RegistrySAXParserFactory cannot b ...

  9. Caused by: java.lang.ClassCastException: org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer错误解决办法

    严重: Failed to initialize end point associated with ProtocolHandler ["http-bio-8080"] java. ...

随机推荐

  1. 手机端QQ客服直接跳转到QQ

    企业QQ呼出QQ对话框方法 1.手机端链接是这样的:mqqwpa://im/chat?chat_type=wpa&uin=386807630&version=1&src_typ ...

  2. Atom package安装失败的解决方案

    cd ~/.atom/package git clone [package url] cd [package name] apm install [package name] if lack some ...

  3. 在Adobe Reader中保存PDF表单数据的方法

    通常,Adobe Reader 用户填写表单后,是无法保存所填表单的副本的.但是,对于 Reader 8 和更高版本的用户,您可以扩展其权限,使他们可以完成此操作.如果您使用的是 Acrobat Pr ...

  4. Kent Beck揭秘Facebook开发部署流程

    http://www.infoq.com/cn/news/2013/10/facebook-development-deployment Facebook是世界上最大的社交网站,有超过10亿用户每月至 ...

  5. WIN7 IIS ASP网站 打不开的解决办法

    WIN7 IIS ASP网站 打不开,通常是访问ACCESS数据库的报错了但在未对IIS和IE作设置的情况,是不能正确的显示错误的,从而也不能解决问题 为解决这个问题,我在网上找了很久,虽然最终解决了 ...

  6. frameset iframe用来分页

    frameset用来分大的框架 iframe用来在frame分框架之后,内嵌分割. <FRAMESET border=1 frameSpacing=1 borderColor=#47478d r ...

  7. cf C. Arithmetic Progression

    http://codeforces.com/contest/382/problem/C 题意:给你n个数,然后让你添加一个数使得n+1个数能形成这样的规律,a[1]-a[0]=a[2]-a[1]=a[ ...

  8. 模拟I2C从机

    模拟I2C主机的比较多,但是从机相对主机而言要难很多,这个供大家借鉴. 这个从机程序支持主机对它的随机写和随机读,连续读和连续写没做,有兴趣的可以完善下,呵呵. //Microcontrol CODE ...

  9. GPIO模拟串口注意是事项

    GPIO模拟串口需要注意的事项如下:(程序见我的博客第一篇) 1.由于串口是异步通信,则串口发送必须满足宽度要求. (1)假设串口的波特率是9600bps(1s传输9600个bit),则传输1bit需 ...

  10. 我的VSTO之路(二):VSTO程序基本知识

    原文:我的VSTO之路(二):VSTO程序基本知识 开始之前,首先我介绍一下我的开发环境:VS2010 + Office 2010,是基于.Net framework 4.0和VSTO 4.0.以下的 ...