Android Java.lang.IllegalArgumentException:pointerIndex out of range

Source: Internet
Author: User

Reprint Please specify: 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 range11-27 00:12:55.029:e/androidruntime (22447): at      android.view.MotionEvent.nativeGetAxisValue (Native Method)


Reason

When drawing, multi-touch zoom out leads to a

I'm in the Viewpager. Zooming in and out by hand-drawn images caused this bug.


My solution for Viewpager:

1 Inherit view

2 rewrite dispatchtouchevent

3 Catch exception

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;       }}


There are other ways online such as:

Overriding the Onintercepttouchevent and Ontouchevent methods

Try catch the two methods, which are shaped as follows:

Try{super.onintercepttouchevent (motionevent ev)} catch (IllegalArgumentException ex) {}return false;try{ Super.ontouchevent (motionevent ev)} catch (IllegalArgumentException ex) {}return false;

Reference: http://nanjingjiangbiao-t.iteye.com/blog/1794478


//┏┓┏┓//┏┛┻━━━┛┻┓//┃┃//┃━┃//┃┳┛┗┳┃//┃┃//┃┻┃//┃┃//┗━┓┏━┛//┃┃ God beast bless//┃┃ Code No bug! //┃┗━━━┓//┃┣┓//┃┏┛//┗┓┓┏━┳┓┏┛//┃┫┫┃┫┫//┗┻┛┗┻┛

Daily Diligence




Android Java.lang.IllegalArgumentException:pointerIndex out of range

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.