ListView中使用type需要注意的东西 java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 addScrapView

ListView中使用type需要注意的东西

在使用ListView时,如果使用了getItemViewType, 记得他的值一定要是从0开始计数的。 且要覆盖getViewTypeCount方法。并且让getViewTypeCount>getItemViewType

否则会有数组越界异常:

10-21 20:18:16.231: E/AndroidRuntime(4475): java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
10-21 20:18:16.231: E/AndroidRuntime(4475):     at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:6437)
10-21 20:18:16.231: E/AndroidRuntime(4475):     at android.widget.ListView.layoutChildren(ListView.java:1559)
10-21 20:18:16.231: E/AndroidRuntime(4475):     at android.widget.AbsListView.onLayout(AbsListView.java:2102)
10-21 20:18:16.231: E/AndroidRuntime(4475):     at se.davison.sodatools.widget.SectionListView.onLayout(SectionListView.java:147)
10-21 20:18:16.231: E/AndroidRuntime(4475):     at android.view.View.layout(View.java:13754)
10-21 20:18:16.231: E/AndroidRuntime(4475):     at android.view.ViewGroup.layout(ViewGroup.java:4362)

  

时间: 2024-08-18 01:09:53

ListView中使用type需要注意的东西 java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 addScrapView的相关文章

android listview Caused by: java.lang.ArrayIndexOutOfBoundsException: length=3; index=3

android listview 适配器在多种类型viewType报错: Caused by: java.lang.ArrayIndexOutOfBoundsException: length=3; index=3 2 at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:6822) 3 at android.widget.AbsListView.trackMotionScroll(AbsListView.j

多线程AsyncTask中使用Jsoup 报错Caused by: java.lang.NoClassDefFoundError: org.jsoup.Jsoup

代码如下,在多线程AsyncTask类中的doInBackground调用Jsoup protected String doInBackground(String... params) { // TODO Auto-generated method stub Log.i(TAG, "doInBackground(Params... params) called"); try { Document doc=Jsoup.connect(params[0]).get(); Elements

【转】Android中引入第三方Jar包的方法(java.lang.NoClassDefFoundError解决办法)

原文网址:http://www.blogjava.net/anchor110/articles/355699.html 1.在工程下新建lib文件夹,将需要的第三方包拷贝进来.2.将引用的第三方包,添加进工作的build path.3.(关键的一步)将lib设为源文件夹.如果不设置,则程序编译可以通过,但运行的时候,会报: java.lang.NoClassDefFoundError # re: Android中引入第三方Jar包的方法(java.lang.NoClassDefFoundErro

【Android】ListView ViewHolder ArrayIndexOutOfBoundsException: length=2; index=2

ViewHolder ArrayIndexOutOfBoundsException: length=2; index=2 http://stackoverflow.com/questions/28387892/viewholder-arrayindexoutofboundsexception-length-2-index-2 ListView Adapter的getItemViewType返回值要从0开始,坑啊!!!

开发中遇到的问题(一)——java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

1.错误描述: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 2.起因: 在Manifest中设置我的activity全屏 1 <activity android:name=".SplashActivity" 2 android:theme="@android:style/Theme.Black.No

Eclipse中使用recyclerview时出现Caused by: java.lang.NoClassDefFoundError: android.support.v7.recyclerview.R$styleable

转自: http://blog.csdn.net/chenleicpp/article/details/46848785 程序崩溃,错误提示: Caused by: java.lang.NoClassDefFoundError: android.support.v7.recyclerview.R$styleable 原因: 在eclipse中使用RecyclerView,编译没有问题,但是运行时候会出现如下错误,百思不得其解,又说v4包与v7包版本不一致,有说没有导入v7-compat包的,经反

Hadoop中RPC协议小例子报错java.lang.reflect.UndeclaredThrowableException解决方法

最近在学习传智播客吴超老师的Hadoop视频,里面他在讲解RPC通信原理的过程中给了一个RPC的小例子,但是自己编写的过程中遇到一个小错误,整理如下: log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).log4j:WARN Please initialize the log4j system properly.log4j:WARN See

Tomcat中使用commons-io-2.5发生的错误java.lang.ClassNotFoundException: org.apache.commons.io.IOUtils

关键词:IntelliJ IDEA.Tomcat.commons-io-2.5.jar.java.lang.ClassNotFoundException: org.apache.commons.io.IOUtils 1.错误提示信息 图1 运行登录时错误信息 //Tomcat Localhost Log信息 org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Servlet] in

【转载】java项目中经常碰到的内存溢出问题: java.lang.OutOfMemoryError: PermGen space, 堆内存和非堆内存,写的很好,理解很方便

Tomcat Xms Xmx PermSize MaxPermSize 区别 及 java.lang.OutOfMemoryError: PermGen space 解决 解决方案 在 catalina.bat 里的 蓝色代码前加入: 红色代码 rem ----- Execute The Requested Command --------------------------------------- set JAVA_OPTS=%JAVA_OPTS%-server -Xms800m -Xmx1