android - ArrayIndexOutOfBoundsException when scrolling too fast in ListView. Bug? -
so have custom listview w/c has embedded onswipeleft , onswiperight listeners , filled array of textviews.
i'm on stage of app testing have found bug in app. error occurs when i'm doing scrolling-too-fast-up-and-down again-and-again.
i set try-catch-block on every array accessing in code exception doesn't caught up.
it seems me error occurs when accidentally tap on 1 of listview's item while still scrolling (the event occurs outside clipping bounds of listview?)
the exact error logs:
06-20 17:29:47.063: d/androidruntime(18336): shutting downwards vm 06-20 17:29:47.063: w/dalvikvm(18336): threadid=1: thread exiting uncaught exception (group=0x40015560) 06-20 17:29:47.092: e/androidruntime(18336): fatal exception: main 06-20 17:29:47.092: e/androidruntime(18336): java.lang.arrayindexoutofboundsexception 06-20 17:29:47.092: e/androidruntime(18336): @ android.view.motionevent.gety(motionevent.java:903) 06-20 17:29:47.092: e/androidruntime(18336): @ android.widget.abslistview.ontouchevent(abslistview.java:2184) 06-20 17:29:47.092: e/androidruntime(18336): @ android.widget.listview.ontouchevent(listview.java:3446) 06-20 17:29:47.092: e/androidruntime(18336): @ android.view.view.dispatchtouchevent(view.java:3885) 06-20 17:29:47.092: e/androidruntime(18336): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:903) 06-20 17:29:47.092: e/androidruntime(18336): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:942) 06-20 17:29:47.092: e/androidruntime(18336): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:942) 06-20 17:29:47.092: e/androidruntime(18336): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:942) 06-20 17:29:47.092: e/androidruntime(18336): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:942) 06-20 17:29:47.092: e/androidruntime(18336): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:942) 06-20 17:29:47.092: e/androidruntime(18336): @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:1691) 06-20 17:29:47.092: e/androidruntime(18336): @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1125) 06-20 17:29:47.092: e/androidruntime(18336): @ android.app.activity.dispatchtouchevent(activity.java:2096) 06-20 17:29:47.092: e/androidruntime(18336): @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:1675) 06-20 17:29:47.092: e/androidruntime(18336): @ android.view.viewroot.deliverpointerevent(viewroot.java:2194) 06-20 17:29:47.092: e/androidruntime(18336): @ android.view.viewroot.handlemessage(viewroot.java:1878) 06-20 17:29:47.092: e/androidruntime(18336): @ android.os.handler.dispatchmessage(handler.java:99) 06-20 17:29:47.092: e/androidruntime(18336): @ android.os.looper.loop(looper.java:123) 06-20 17:29:47.092: e/androidruntime(18336): @ android.app.activitythread.main(activitythread.java:3683) 06-20 17:29:47.092: e/androidruntime(18336): @ java.lang.reflect.method.invokenative(native method) 06-20 17:29:47.092: e/androidruntime(18336): @ java.lang.reflect.method.invoke(method.java:507) 06-20 17:29:47.092: e/androidruntime(18336): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 06-20 17:29:47.092: e/androidruntime(18336): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 06-20 17:29:47.092: e/androidruntime(18336): @ dalvik.system.nativestart.main(native method) i'm quite sure it's on swipelisteners because if didn't set this
listview.setontouchlistener( new onswipetouchlistener(this) { public void onswiperight() { loadnextpage(); } public void onswipeleft() { loadprevpage(); } }); no error occurring.
what did rid of on implementation of swipelisteners w/c exactly
public class onswipetouchlistener implements ontouchlistener then changing default one
@override public boolean ondown(motionevent e) { homecoming true; } to this
@override public boolean ondown(motionevent e) { homecoming false; } and error has gone. still kind of work around haunt me in future work , think nobody way. might things missed?
if not using viewholder pattern should utilize makes listview scrolling smooth reusing views. few sources are:
hope helps. :)
android android-listview
No comments:
Post a Comment