Android java.lang.IllegalArgumentException: pointerIndex out of range

转载请注明:http://blog.csdn.net/aaawqqq

Android   java.lang.IllegalArgumentException: pointerIndex out of range

bug:

11-27 00:12:55.029: E/AndroidRuntime(22447): java.lang.IllegalArgumentException: pointerIndex out of range
11-27 00:12:55.029: E/AndroidRuntime(22447):      at android.view.MotionEvent.nativeGetAxisValue(Native Method)

原因

绘图的时候 多点触控 放大缩小 导致一场

我在viewpager 里面  通过手势绘制图片 放大缩小 造成了这个bug

我的 viewpager 解决方案:

1 继承 view

2 重写 dispatchTouchEvent

3 抓住异常

public class FixedViewPager extends ViewPager {
        public FixedViewPager(Context context) {
               super(context);
       }

        public FixedViewPager(Context context, AttributeSet attrs) {
               super(context, attrs);
       }

        @Override
        public boolean dispatchTouchEvent(MotionEvent ev) {
               try {
                      return super .dispatchTouchEvent(ev);
              } catch (IllegalArgumentException ignored) {
              } catch (ArrayIndexOutOfBoundsException e) {
              }

               return false ;

       }
}

网上有其它方法 如:

重写onInterceptTouchEvent 和onTouchEvent方法

try catch 该两个方法,形如下面:

try{
super.onInterceptTouchEvent(MotionEvent ev)
} catch(ILLegalArgumentException ex) {
}
return false;
try{
super.onTouchEvent(MotionEvent ev)
} catch(ILLegalArgumentException ex) {
}
return false;

参考: http://nanjingjiangbiao-t.iteye.com/blog/1794478

//┏┓   ┏┓

//┏┛┻━━━┛┻┓

//┃       ┃  

//┃   ━   ┃

//┃ ┳┛ ┗┳ ┃

//┃       ┃

//┃   ┻   ┃

//┃       ┃

//┗━┓   ┏━┛

//  ┃   ┃   神兽保佑        

//  ┃   ┃   代码无BUG!

//  ┃   ┗━━━┓

//  ┃       ┣┓

//  ┃       ┏┛

//  ┗┓┓┏━┳┓┏┛

//    ┃┫┫ ┃┫┫

//    ┗┻┛ ┗┻┛

每日精进

时间: 2024-10-10 21:16:52

Android java.lang.IllegalArgumentException: pointerIndex out of range的相关文章

Android 多点触控错误处理(java.lang.IllegalArgumentException: pointerIndex out of range)

最近做View的多点触控时,每次第一次触控事件完美运行,第二次就直接崩了,错误信息如下: 01-03 00:05:44.220 4377-4410/system_process E/AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: android.ui java.lang.IllegalArgumentException: pointerIndex out of range at android.view.MotionEvent.nat

图片缩放时java.lang.IllegalArgumentException: pointerIndex out of range解决方案

版权声明:本文为博主原创文章,未经博主允许不得转载. 06-03 20:45:24.143: E/AndroidRuntime(1230): FATAL EXCEPTION: main06-03 20:45:24.143: E/AndroidRuntime(1230): java.lang.IllegalArgumentException: pointerIndex out of range06-03 20:45:24.143: E/AndroidRuntime(1230): at androi

java.lang.IllegalArgumentException: pointerIndex out of range两种解决办法

java.lang.IllegalArgumentException: pointerIndex out of range 在做拍摄海报功能的时候需要拍摄界面的surface进行手势缩放,做多点触控放大缩小,操作时发生这个异常,如果是操作图片的放大缩小多点触控不会出现这个错误,这个bug是Android系统原因此处给出两种解决方式: 第一种方式是: 修改frameworks\base\core\jni\android_view_MotionEvent.cpp的android_view_Motio

图片缩放时java.lang.IllegalArgumentException: pointerIndex out of range

06-03 20:45:24.143: E/AndroidRuntime(1230): FATAL EXCEPTION: main 06-03 20:45:24.143: E/AndroidRuntime(1230): java.lang.IllegalArgumentException: pointerIndex out of range 06-03 20:45:24.143: E/AndroidRuntime(1230): at android.view.MotionEvent.native

java.lang.IllegalArgumentException: pointerIndex out of range错误

项目中要实现滑屏展示图片,并且图片可以放大缩小,使用了ViewPager实现需求,但在缩小图片时保了java.lang.IllegalArgumentException: pointerIndex out of range这个错误,查阅资料发现这个是Android系统的bug,找到了解决办法,,捕获IllegalArgumentException异常 查看报错日志at android.support.v4.view.ViewPager.onInterceptTouchEvent(ViewPage

解决多指操作放大缩小 指针错误 java.lang.IllegalArgumentException: pointerIndex out of range

/** Custom your own ViewPager to extends support ViewPager. java source: */ /** Created by azi on 2013-6-21. */ package com.chaokuadi.android.support.view; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEv

android java.lang.IllegalArgumentException: Comparison method violates its general contract! 问题

android  java.lang.IllegalArgumentException: Comparison method violates its general contract! 问题 java.lang.IllegalArgumentException: Comparison method violates its general contract! at java.util.TimSort.mergeLo(TimSort.java:743) at java.util.TimSort.

Android - java.lang.IllegalArgumentException: Receiver not registered

java.lang.IllegalArgumentException: Receiver not registered 从平台上可以看到Crash的错误问题, 出现了以下这条 java.lang.IllegalArgumentException: Receiver not registered 明明我OnResume有注册.OnPause有移除. 但为什么会发生这个问题 private BroadcastReceiver mReceiver = new BroadcastReceiver() {

Android java.lang.IllegalArgumentException: Object returned from onCreateLoader must not be a non-static inn

AsyncTaskLoader: http://developer.Android.com/intl/zh-CN/reference/android/content/AsyncTaskLoader.html 错误信息: java.lang.IllegalArgumentException: Object returned from onCreateLoader must not be a non-static inner member class: DownloadTask 原因: public