我遇到以下异常:
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)
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)
当简单地放置2个手指并将它们拖动一小段距离时。应用程序停止并存在。我在下面发布我的代码。
这段代码是处理我的视图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;
}
};
任何帮助?
答案 0 :(得分:0)
问题在于event.getPointerCount(),将此行放入try catch块或只是添加一个日志,你会发现它。你想用这个scrollView做什么。