java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
2016-09-21 19:36
666 查看
转载请注明出处:http://blog.csdn.net/harryweasley/article/details/52612239
最近做一个项目,遇到了一个bug,在此进行记录一下。
自定义view,在用到ViewDragHelper时候,报以下的错误:
错误第二行
显示viewDragHelper:1172报错,
这句话数组越界。
因为viewDragHelp是系统源码的,我们没必要在这里进行修改,接下来看看第三行
DropALlChildView是我自定义的一个view,它的76行报错,76行处的代码,就这一句话:
我们可以看出来,是因为调用了mDragger.shouldInterceptTouchEvent(event);报错的,所以在这里进行一个try catche判断:
这样就解决了此问题。
其实这个是多点触碰导致的错误。
最近做一个项目,遇到了一个bug,在此进行记录一下。
自定义view,在用到ViewDragHelper时候,报以下的错误:
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 at com.seeyon.mobile.android.model.common.content.view.drag.ViewDragHelper.shouldInterceptTouchEvent(ViewDragHelper.java:1172) at com.seeyon.mobile.android.model.common.view.DropAllChildView.onInterceptTouchEvent(DropAllChildView.java:76) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2143) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2318)
错误第二行
at com.seeyon.mobile.android.model.common.content.view.drag.ViewDragHelper.shouldInterceptTouchEvent(ViewDragHelper.java:1172)
显示viewDragHelper:1172报错,
final float dx = x - mInitialMotionX[pointerId];
这句话数组越界。
因为viewDragHelp是系统源码的,我们没必要在这里进行修改,接下来看看第三行
at com.seeyon.mobile.android.model.common.view.DropAllChildView.onInterceptTouchEvent(DropAllChildView.java:76)
DropALlChildView是我自定义的一个view,它的76行报错,76行处的代码,就这一句话:
@Override public boolean onInterceptTouchEvent(MotionEvent event) { return mDragger.shouldInterceptTouchEvent(event); }
我们可以看出来,是因为调用了mDragger.shouldInterceptTouchEvent(event);报错的,所以在这里进行一个try catche判断:
@Override public boolean onInterceptTouchEvent(MotionEvent event) { // return mDragger.shouldInterceptTouchEvent(event); try { //某些手机在双点操作的时候会报此错误,在此进行捕捉。 return mDragger.shouldInterceptTouchEvent(event); } catch (ArrayIndexOutOfBoundsException e) { return false; } }
这样就解决了此问题。
其实这个是多点触碰导致的错误。
相关文章推荐
- java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
- Java - 错误: "java.lang.ArrayIndexOutOfBoundsException: length=1; index=1"
- java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
- Android问题集-RecyclerView--java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
- BaseAdapter java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 dispatchTouchEvent
- AsyncTask params java.lang.ArrayIndexOutOfBoundsException: length=0; index=0异常
- java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 异常处理
- adapter适配器中有不同item时可能会报java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
- ListView同一个适配器设置不同的item时遇到java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
- Android-71-解决报错: java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
- java.lang.ArrayIndexOutOfBoundsException: length=13; index=14 android.widget.AbsListView$RecycleBin.
- ListView报错:ListView中使用type需要注意的东西 java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 addScr
- android listview Caused by: java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
- ListView中使用type需要注意的东西 java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 addScrapView
- ListView中使用type需要注意的东西 java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 addScrapView
- java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
- 在Eclipse中测试Main函数运行出现Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:0
- [经验小结]jxl写excel时产生“java.lang.ArrayIndexOutOfBoundsException: 5”问题的解决办法
- Proguard 4.x error - java.lang.ArrayIndexOutOfBoundsException
- AXMLPrinter2.jar反编译xml文件时 java.lang.ArrayIndexOutOfBoundsException错误