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 ...
随机推荐
- Node调试之道-----JSHint
Node调试之道-----JSHint Node的优势我就不再乱吹捧了,它让javascript统一web的前后台成为了可能.但是对于新手来说,server端的JS代码可能不像client端的代码那么 ...
- IIS-Server is too busy _解决方法
httpRuntime Server Too Busy 修改方法:修改服务器.net配置“machine.config"文件,该文件位于Windows系统目录下,如“C:\WINDOWS \Micro ...
- [zz]计算 协方差矩阵
http://www.cnblogs.com/chaosimple/p/3182157.html http://blog.csdn.net/goodshot/article/details/86111 ...
- Correlation Filter in Visual Tracking系列二:Fast Visual Tracking via Dense Spatio-Temporal Context Learning 论文笔记
原文再续,书接一上回.话说上一次我们讲到了Correlation Filter类 tracker的老祖宗MOSSE,那么接下来就让我们看看如何对其进一步地优化改良.这次要谈的论文是我们国内Zhang ...
- android学习笔记51——SQLite 手势Gesture
手势Gesture 所谓手势,是指用户手指或触摸笔在触摸屏幕上的连续触碰行为. Androi对两种手势行为都提供了支持: 1.对于第一种手势而言,android提供了手势检测,并为手势检测提供了相应的 ...
- 使用C#和.NET的原因
早在2000年6月,微软公布.NET之后不久,Ximian公司诞生了一个开源项目叫做Mono,运行在Linux环境下面的C#编译器和.NET Framework.十年后,在2011年,Ximian的创 ...
- [FFmpeg] ffmpeg参数详解
ffmpeg 参数语法 ffmpeg [[options][`-i' input_file]]... {[options] output_file}... 如果没有输入文件,那么视音频捕捉就会起作用. ...
- [ActionScript 3.0] AS3.0 对象在矩形范围随机运动
package com.views { import flash.display.Bitmap; import flash.display.MovieClip; import flash.displa ...
- zmap使用笔记
zmap使用笔记 zmap, 一个网络端口开放性的快速扫描工具.至于这个工具的特色,配置参数,和比的工具的对比,不做介绍.只记录一下近期使用过程中,遇到的问题.软件版本:2.1.1 传言与现实 传言: ...
- Flex 加载shp
至于gis格式比较常见的shp是开源的,网上开源的as代码也很多 这个支持的shp算比较好的 源码在这边http://files.cnblogs.com/files/haibalai/shp.rar, ...