java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView
最近在学习drawerLayout时,遇到这个bug。如下示:
java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView
原因:
可能是没有在适配器参数内加入TextView的id.
解决方案:
将原来的适配器参数代码
mDrawerList.setAdapter(new ArrayAdapter<String>(this,R.layout.list_item,datas));
修改为以下形式即可:
mDrawerList.setAdapter(new ArrayAdapter<String>(this,R.layout.list_item,R.id.text_view,datas));
其他的解决方案,参见stack overflow:
http://stackoverflow.com/questions/20290735/java-lang-classcastexception-android-widget-linearlayout-cannot-be-cast-to-andr
http://stackoverflow.com/questions/10869197/android-widget-linearlayout-cannot-be-cast-to-android-widget-textview
java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView的更多相关文章
- 关于android使用ksoap2报Caused by: java.lang.ClassCastException: org.ksoap2.SoapFault cannot be cast to org.ksoap2.serialization.SoapObject
Caused by: java.lang.ClassCastException: org.ksoap2.SoapFault cannot be cast to org.ksoap2.serializa ...
- 加载程序到android虚拟机报错: android.widget.RelativeLayout cannot be cast to android.widget.Button
05-23 02:53:48.416: E/Trace(875): error opening trace file: No such file or directory (2) 05-23 02:5 ...
- java.lang.ClassCastException: oracle.sql.CLOB cannot be cast to oracle.sql.CLOB
错误现象: [framework] 2016-05-26 11:34:53,590 -INFO [http-bio-8080-exec-7] -1231863 -com.dhcc.base.db.D ...
- java.lang.ClassCastException: oracle.sql.TIMESTAMP cannot be cast to java.sql.Timestamp
http://stackoverflow.com/questions/13269564/java-lang-classcastexception-oracle-sql-timestamp-cannot ...
- java.lang.ClassCastException: sun.proxy.$Proxy11 cannot be cast to分析
报这个错,只有一个原因,就是你转化的类型不对. 如果你的类是一个单实体类,也就是没有继承或是接口别的类. public class HjmServiceImpl {} 那么这样写就可以: HjmSer ...
- 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 ...
- java.lang.ClassCastException android.widget.RelativeLayout LayoutParams 异常
1.在xml布局文件如下所示: <RelativeLayout android:layout_width="match_parent" android:layout_heig ...
- Exception: java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
RelativeLayout title_bg = (RelativeLayout)FTU_Bluetooth.this.findViewById(R.id.titlebar); LinearLayo ...
- 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 ...
随机推荐
- 2017.1.8a版给信息源新增:max_len、max_db字段
2017.1.8a版程序给信息源增加max_len.max_db字段,分别用于控制:获取条数.数据库保留条数. max_len的说明见此图: max_db的说明见此图: 当max_len和max_db ...
- 既使用maven又使用本地Jar包
maven 使用本地包 lib jar包 依赖一个lib目录 解决方法: 1. 把本地的lib加入maven编译时的依赖路径 如下配置: <plugin> <artifactId&g ...
- android国际化操作
1.简单介绍 我们知道在java中通过.properties文件来配置资源文件,一般用的有中文message_zh_CN.properties和英文message_en_US.properties两个 ...
- SQL Server 2008 收缩日志 清空删除大日志文件 转载
SQL Server 2008 收缩日志 清空删除大日志文件 由于SQL2008对文件和日志管理进行了优化,所以以下语句在SQL2005中可以运行但在SQL2008中已经被取消:(SQL2005)Ba ...
- Eclipse 配置Maven
Eclipse 配置Maven 下载Maven 首先在官网下载Maven:http://maven.apache.org/download.cgi 下载后将其解压到相应的位置 配置Maven环境变量 ...
- ADF_Desktop Integration系列1_ADF桌面集成入门之设定Development Environment
2013-05-01 Created By BaoXinjian
- load、init和initialize的区别
在NSObject.h中找到三个方法 + (void)load; + (void)initialize; - (instancetype)init 1. 可知三个方法类型,两个类方法,一个对象方法 2 ...
- Windows自带的驱动程序例子都在哪里?
MSDN官方说明:https://msdn.microsoft.com/windows/hardware/drivers/samples/index 各个操作系统驱动例子: Windows10 :h ...
- CGContextAddArcToPoint和CGContextAddArc
比较难的是CGContextAddArcToPoint 代码如下: CGContextRef context=UIGraphicsGetCurrentContext(); CGContextSetRG ...
- 黑马程序员_ JAVA中的多线程
------- android培训.java培训.期待与您交流! ---------- 尽管线程对象的常用方法可以通过API文档来了解,但是有很多方法仅仅从API说明是无法详细了解的. 本来打算用一节 ...