java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.L(转)
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(转)的更多相关文章
- 解决 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 关于利用动态代理手写数据库连接池的异常 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 ...
- java.lang.ClassCastException: com.sun.proxy.$Proxy2 cannot be cast to...异常
异常: Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy2 cannot ...
- 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 ...
- 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. ...
随机推荐
- PHP 用户注册
注册页面 reg.html 负责收集用户填写的注册信息.教程里只列出关键的代码片段,完整的代码附在本节最后. 注册表单 <fieldset> <legend>用户注册</ ...
- cygwin编译ffmpeg移植到android平台问题集锦
编译环境: windows xp Cygwin 1.1.3.1 NDK r9 1.提示各种command not found 比如 ./config.sh: line 6: $'--arch=arm\ ...
- Python使用纯真年代数据库qqwry.dat转换物理位置
PS:网上直接找的,贴出来,方便以后随时用,感谢分享的人. #!/usr/bin/python #encoding: utf-8 import socket import codecs import ...
- 【Linux】常用命令-统计代码行数
公司人员流动大,经常有新的维护任务,交接时喜欢看看新来的模块的代码量,那么问题来了, 如何统计代码行数? 1,最先想到的肯定是 wc. wc -l *.h 将查看[当前目录]下头文件的代码行数,输出结 ...
- C语言连接MySql数据库
C语言连接MySql数据库(CodeBlocks) 操作系统:Windows7(32位)编译软件:Code::Blocks 10.05数 据 库:mysql-5.1.62-win32 数据库内的数据: ...
- Sphnix创建文档
http://www.ibm.com/developerworks/cn/opensource/os-sphinx-documentation/ Oracle实例名和服务名
- codeforces C. Xor-tree
http://codeforces.com/problemset/problem/430/C 题意:在一棵上有n个节点,有n-1条边,在每一个节点上有一个值0或1,然后给你一个目标树,让你选择节点,然 ...
- JSP出现中文乱码问题
今天纠结了好半天,本地运行程序后没有中文乱码,唯独发到服务器后运行出现了乱码. 究其原因,皆因eclipse环境默认的JSP编码是Iso-8859-1,需要将其改为utf-8,与JSP文件中的编码声明 ...
- Linux kernel ‘ip6_sk_dst_check’函数拒绝服务漏洞
漏洞名称: Linux kernel ‘ip6_sk_dst_check’函数拒绝服务漏洞 CNNVD编号: CNNVD-201307-070 发布时间: 2013-07-05 更新时间: 2013- ...
- Light OJ 1018 - Brush (IV)
题目大意: 一个二维平面上有N个点,一把刷子,刷一次可以把一条线上的所有点都刷掉.问最少刷多少次,可以把全部的点都刷完 状态压缩DP, 用记忆化搜索来写, 需要有个优化不然会超时. ===== ...