java.lang.IllegalArgumentException: pointerIndex out of range
2014-08-06 10:29
435 查看
在ViewPager里缩放图片过小出的异常,自己看了网上的方法:
1.让你的view(可能是ScrollView,WebView,MapView等),创建一个子view继承于它们中的某一个;
2.重写onInterceptTouchEvent 和onTouchEvent方法
3.try catch 该两个方法,形如下面:
try{
super.onInterceptTouchEvent(MotionEvent ev)
} catch(ILLegalArgumentException ex) {
}
return false;
try{
super.onTouchEvent(MotionEvent ev)
} catch(ILLegalArgumentException ex) {
}
return false;
Tips:但是有点问题,如果是用ViewPager的话,onInterceptTouchEvent 返回false会导致ViewPager翻页出现BUG
1.让你的view(可能是ScrollView,WebView,MapView等),创建一个子view继承于它们中的某一个;
2.重写onInterceptTouchEvent 和onTouchEvent方法
3.try catch 该两个方法,形如下面:
try{
super.onInterceptTouchEvent(MotionEvent ev)
} catch(ILLegalArgumentException ex) {
}
return false;
try{
super.onTouchEvent(MotionEvent ev)
} catch(ILLegalArgumentException ex) {
}
return false;
Tips:但是有点问题,如果是用ViewPager的话,onInterceptTouchEvent 返回false会导致ViewPager翻页出现BUG
import android.content.Context; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.MotionEvent; /** * ViewPager类,(此类只是为了防止双指缩放过小而出异常) * @author * */ public class ImageViewPager extends ViewPager { public ImageViewPager(Context context) { super(context); } public ImageViewPager(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent arg0) { boolean b = false; try { b = super.onInterceptTouchEvent(arg0); } catch (Exception e) { } return b; //网上看的方法是直接返回false,但是会导致ViewPager翻页有BUG } @Override public boolean onTouchEvent(MotionEvent arg0) { try { super.onTouchEvent(arg0); } catch (Exception e) { } return false; } }
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <!-- ViewPager用自己定义的 --> <com.ghl.components.ImageViewPager android:id="@+id/show_image_viewpager" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#4000" /> <include layout="@layout/image_selector_titlebar"/> <include layout="@layout/image_selector_bottom"/> </RelativeLayout>我是这样处理ViewPager翻页就没问题了。
相关文章推荐
- java.lang.IllegalArgumentException: pointerIndex out of range
- 解决java.lang.IllegalArgumentException: pointerIndex out of range的错误
- java.lang.IllegalArgumentException: pointerIndex out of range两种解决办法
- 解决多指操作放大缩小 指针错误 java.lang.IllegalArgumentException: pointerIndex out of range
- java.lang.IllegalArgumentException: pointerIndex out of range 问题的两种解决办法
- java.lang.IllegalArgumentException: pointerIndex out of range
- Android 中 java.lang.IllegalArgumentException: pointerIndex out of range 异常的处理方法
- 图片缩放时java.lang.IllegalArgumentException: pointerIndex out of range
- java.lang.IllegalArgumentException: pointerIndex out of range
- java.lang.IllegalArgumentException: pointerIndex out of range
- 图片缩放时java.lang.IllegalArgumentException: pointerIndex out of range解决方案
- 解决图片缩放时异常:java.lang.IllegalArgumentException: pointerIndex out of range
- 完美解决java.lang.IllegalArgumentException: pointerIndex out of range
- ViewPager中的图片多点触摸出现java.lang.IllegalArgumentException: pointerIndex out of range解决方案
- 图片缩放时java.lang.IllegalArgumentException: pointerIndex out of range解决方案
- 解决java.lang.IllegalArgumentException: pointerIndex out of range 或者 arrayindexoutofboundsexception的错误
- 图片缩放时java.lang.IllegalArgumentException: pointerIndex out of range解决方案
- java.lang.IllegalArgumentException: pointerIndex out of range 问题的两种解决办法
- java.lang.IllegalArgumentException:pointerIndex out of range问题的两种解决办法
- Android4.1上出现java.lang.IllegalArgumentException: pointerIndex out of range