1、在xml布局文件如下所示:

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:paddingBottom="5dp"
android:paddingTop="5dp" > <View
android:id="@+id/slide_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/slide_background" /> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" > <RelativeLayout
android:id="@+id/rl_conversation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >

2、在java.class文件中获取控件mSlideView的布局参数getLayoutParams, 运行过程中出现

java.lang.ClassCastException android.widget.RelativeLayout LayoutParams 异常,经过查找资料,发现引用包错了。

// 得到会话布局的参数,设置给滑块 ( 因为这个view的父布局是 RelativeLayout)

LayoutParams lp = (LayoutParams) mSlideView.getLayoutParams();
所以得引用 import android.widget.RelativeLayout.LayoutParams;

不能引用系统默认引用的包 import android.widget.LinearLayout.LayoutParams;

java.lang.ClassCastException android.widget.RelativeLayout LayoutParams 异常的更多相关文章

  1. Exception: java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams

    RelativeLayout title_bg = (RelativeLayout)FTU_Bluetooth.this.findViewById(R.id.titlebar); LinearLayo ...

  2. 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.w ...

  3. java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView

    最近在学习drawerLayout时,遇到这个bug.如下示: java.lang.ClassCastException: android.widget.RelativeLayout cannot b ...

  4. Caused by: java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams

    最近,在android中用代码动态改变某种布局(组件)的高度时,会遇到如题所示的类转换异常.上网查了一下,如下所示: These supply parameters to the parent of ...

  5. 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: main09-09 10:19:59.979: E/AndroidRuntim ...

  6. 关于java.lang.NoSuchMethodError: android.widget.RelativeLayout.setBackground的解决办法

    今天用一个安卓4.0.4版本的手机测试手上的项目,发现logcat弹出这样一个提示“java.lang.NoSuchMethodError: android.widget.RelativeLayout ...

  7. java.lang.ClassCastException: android.widget.ImageButton异常处理

    在调程序时总是出现异常关闭的现象,log显示: 03-26 07:58:09.528: E/AndroidRuntime(398): Caused by: java.lang.ClassCastExc ...

  8. java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText

    Caused by: Java.lang.ClassCastException: Android.widget.TextView cannot be cast to android.widget.Ed ...

  9. 安卓出现错误: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText

    Caused by: Java.lang.ClassCastException: Android.widget.TextView cannot be cast to android.widget.Ed ...

随机推荐

  1. POJ1741:Tree

    浅谈树分治:https://www.cnblogs.com/AKMer/p/10014803.html 题目传送门:http://poj.org/problem?id=1741 这是一道树分治的模板题 ...

  2. 使用Node.js实现简单的网络爬取

    由于最近要实现一个爬取H5游戏的代理服务器,隧看到这么一篇不错的文章(http://blog.miguelgrinberg.com/post/easy-web-scraping-with-nodejs ...

  3. 【转载】“error LNK1169: 找到一个或多个多重定义的符号”的解决方法

    c++的小细节的地方 原文地址:https://blog.csdn.net/xiaosu123/article/details/5665729 问题描述如下: 有 三个源文件,A.h.B.cpp.C. ...

  4. TypeScript完全解读(26课时)_20.声明文件

    首先学习识别已有的js库的类型 识别已有的js库的类型 UMD既可以作为全局库使用,也可以作为模块使用 先在着手来编写一个全局的库 新建文件 接收一个title,改变页面title的值 这里用到 &a ...

  5. jQuery 实现网页跳转或用命令打开指定网页!

    Jquery实现网页跳转或用命令打开指定网页! location.href = "www.baidu.com"; location.href = "aa.aspx&quo ...

  6. LuaToC#

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  7. python-codecs.open()使用举例

    代码: import codecs from unidecode import unidecode def main(): fullFilename="123.txt" inFID ...

  8. Android-毛笔的探索与开发

     前言 这篇文章主要是关于移动端毛笔的开发,在平板上有着书写毛笔字贴的效果. 介绍关于毛笔的算法思路. 项目github地址 算法思路分析 曲线拟合算法 利用曲线拟合算法增加虚拟的点,使得笔迹更加光滑 ...

  9. 1 手写Java ArrayList核心源码

    手写ArrayList核心源码 ArrayList是Java中常用的数据结构,不光有ArrayList,还有LinkedList,HashMap,LinkedHashMap,HashSet,Queue ...

  10. now code——小a和黄金街道(欧拉函数和快速幂模板)

    小a和小b来到了一条布满了黄金的街道上.它们想要带几块黄金回去,然而这里的城管担心他们拿走的太多,于是要求小a和小b通过做一个游戏来决定最后得到的黄金的数量.游戏规则是这样的:假设道路长度为米(左端点 ...