PhotoView+Viewpager开发图集效果的时候,在某些手机上双指缩放的时候出现java.lang.IllegalArgumentException: pointerIndex out of range异常
解决方案:
捕获IllegalArgumentException(非法参数异常)异常
解决方案:
捕获IllegalArgumentException(非法参数异常)异常
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* 图片缩放时java.lang.IllegalArgumentException: pointerIndex out of range解决方案
*
* @see http://blog.csdn.net/nnmmbb/article/details/28419779
*
*/
public class FixedViewPager extends android.support.v4.view.ViewPager {
public FixedViewPager(Context context) {
super(context);
}
public FixedViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
try {
return super.onTouchEvent(ev);
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
return false;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
try {
return super.onInterceptTouchEvent(ev);
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
return false;
}
}