java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
FrameLayout的父控件是一个LinearLayout控件,问题出在,LinearLayout为子控件分配空间的时候,获取FrameLayout的LayoutParams的必须为LinearLayout.LayoutParams,而非FrameLayout.LayoutParams。
简单的举个栗子说明一下:最外层有ReLativeLayout A,里面有两个LinearLayout B、C,而B中又有一个一个FrameLayout D。如果要在代码里设置B的LayoutParams,B的LayoutParams要为RelativeLayout.LayoutParams。
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
B.setLayoutParams(params);
而D要设置的话,需要:
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0);
params.weight = 8;
D.setLayoutParams(params); 还有ListView.LayoutParams
java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams的更多相关文章
- 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. ...
- Caused by: java.lang.ClassCastException: org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer
A child container failed during startjava.util.concurrent.ExecutionException: org.apache.catalina.Li ...
- 开发Spring过程中几个常见异常(三):java.lang.ClassCastException: com.sun.proxy.$Proxy4 cannot be cast to com.edu.aop.ArithmeticCalculatorImpl at com.edu.aop.Main.main(Main.java:11)
这个异常是在开发Spring案例时遇到的. 贴一下完整异常信息: Exception in thread "main" java.lang.ClassCastException: ...
- java.lang.ClassCastException: com.sun.proxy.$Proxy27 cannot be cast to com.bbk.n002.service.QuestionService
1 严重: Servlet /N002-1.0 threw load() exception 2 java.lang.ClassCastException: com.sun.proxy.$Proxy2 ...
随机推荐
- Go语言规格说明书 之 词汇元素(Lexical elements)
go version go1.11 windows/amd64 本文为阅读Go语言中文官网的规则说明书(https://golang.google.cn/ref/spec)而做的笔记,完整的介绍Go语 ...
- 细说MySQL备份的基本原理(系列一 ) 备份与锁
数据库作为一个系统中唯一或者主要的持久化组件,对服务的可用性和数据的可靠性要求极高. 作为能够有效应对因为系统软硬件故障.人工误操作导致数据丢失的预防手段,备份是目前最为常见的数据库运维操作. 考虑到 ...
- Java编程的逻辑 (72) - 显式条件
本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http: ...
- pig cookbook学习
pig cookbook学习 Overview 近期需要用pig做一些统计,由于没有系统学习,问题出现一些问题,且不容易调试,执行效率也不高.所以打算看一些官方文档,在此做些笔记. pig性能提升 指 ...
- windows10系统定时1分钟执行php(不借助windows的.bat文件)原创
第一步:确认windows上是否配置好了php环境变量,我用xampp安装的lamp环境,默认已经配置好了php的环境变量.在CMD中执行php -v 显示相应的php版本 php -v 如果显示上 ...
- docker commit 制作镜像
docker commit -m="commit jdk" --author="gutianlangyu" ae56f6cad215 gutianlangyu/ ...
- PowerDesigner的安装
1.下载 2.步骤 3.效果 二:破解 1.参考文档 https://www.7down.com/soft/180716.html 2.说明 主要是一个文件,替换掉文件中的文件即可.
- vim/sed/awk/grep等文件批处理总结
Vim相关操作 1.基础 * 和 # 对对当前光标所在的单词进行搜索 %匹配括号移动,包括 (, {, [ K 查看man手册 ga 查看ascii值 g CTRL-G 统计字数,使用Visual模式 ...
- jquery获取浏览器各种高宽
$(document).ready(function(){ alert($(window).height()); //浏览器当前窗口可视区域高度 alert($(document).height()) ...
- sublime text3中文乱码问题解决方案
1. 首先需要安装包convertToUTF8,安装完重启后如果仍然不能正常显示中文,则需要进行用户配置. 2.用户配置:preferences>settings 在用户设置加入一个属性:&qu ...