1

I'm getting the following exception:

E/AndroidRuntime(31245): java.lang.IllegalArgumentException: pointerIndex out of range
E/AndroidRuntime(31245):        at android.view.MotionEvent.nativeGetAxisValue(Native Method)
E/AndroidRuntime(31245):        at android.view.MotionEvent.getY(MotionEvent.java:1564)
E/AndroidRuntime(31245):        at android.widget.ScrollView.onTouchEvent(ScrollView.java:628)
E/AndroidRuntime(31245):        at android.view.View.dispatchTouchEvent(View.java:4626)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1554)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1320)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
E/AndroidRuntime(31245):        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
E/AndroidRuntime(31245):        at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1862)
E/AndroidRuntime(31245):        at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1286)
E/AndroidRuntime(31245):        at android.app.Activity.dispatchTouchEvent(Activity.java:2315)
E/AndroidRuntime(31245):        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1835)
E/AndroidRuntime(31245):        at android.view.View.dispatchPointerEvent(View.java:4694)
E/AndroidRuntime(31245):        at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2419)
E/AndroidRuntime(31245):        at android.view.ViewRoot.handleMessage(ViewRoot.java:2080)
E/AndroidRuntime(31245):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(31245):        at android.os.Looper.loop(Looper.java:132)
E/AndroidRuntime(31245):        at android.app.ActivityThread.main(ActivityThread.java:4126)
E/AndroidRuntime(31245):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(31245):        at java.lang.reflect.Method.invoke(Method.java:491)
E/AndroidRuntime(31245):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
E/AndroidRuntime(31245):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)

When simply placing 2 fingers and drag them for a short distance. The appliation stops and exists. I'm posting my code below. This chunk of code is the only piece that handles my view's ontouchlistener.

ScrollView scrollView = (ScrollView) findViewById(R.id.ScrollView11);
        scrollView.setOnTouchListener(textIncreaseListener);
    }

    private OnTouchListener textIncreaseListener = new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            int count = event.getPointerCount();
            if(count == 2){
                Log.d(TAG, "2 pointers");
                return true;
            }
            return false;
        }
    };

Any help?

bardao
  • 914
  • 12
  • 23
  • this link will help you to solve your problem. http://stackoverflow.com/questions/6919292/pointerindex-out-of-range-android-multitouch – Bhavesh Patadiya Sep 11 '12 at 11:28

1 Answers1

0

The Problem is with event.getPointerCount() , put this line into try catch block or simply add a log and you will find it. What exactly you want to do with this scrollView.

PiyushMishra
  • 5,743
  • 6
  • 37
  • 57
  • still have same issue. app crashes as soon as i take my fingers off screen. as if it's generated on release – bardao Sep 11 '12 at 12:14
  • yah it has to crash to put ur code into try catch block is not mean it wont crash its to capture the bug. try{ Log.d("//", event.getPointerCount()+"//") int count = event.getPointerCount(); } tell me the log. – PiyushMishra Sep 11 '12 at 12:17
  • partially worked by removing return true from the if statement and returning true for the whole block but stops the normal scrolling from working. I want to add a pinch to zoom to my scrollview – bardao Sep 11 '12 at 12:21
  • now you got it see you are consuming the event as u are returning true and tell me abt event.getPointerCount() from the log. – PiyushMishra Sep 11 '12 at 12:23
  • it displays 2s until i remove my fingers. it displays 1 then the same exception pops. the exception does not occur always. if i move fast and briefly it posps – bardao Sep 11 '12 at 12:32
  • see the things is you are handling only count==2 else every time its returning the false. IllegalArgumentException: pointerIndex out of range as log suggest your event.getPointerCount() index is out of range. just handle it properly. – PiyushMishra Sep 11 '12 at 12:41