Open bemusementpark opened 9 years ago
I think this could be an error in HeaderViewListAdapter itself. Any insight?
can you provide a sample project or snippet that demonstrates this crash, please?
Is it same problem? I added a footerView to listview and setOnScrollListener for endless scrolling.
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
private boolean isLoading = false;
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (!isLoading && firstVisibleItem + visibleItemCount >= totalItemCount) {
isLoading = true;
// this is fine.
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
adapter.appendItems(demoUtils.moarItems(50));
isLoading = false;
}
}, 1000);
// below line makes crash.
//adapter.appendItems(demoUtils.moarItems(50));
//isLoading = false; }
}
});
I just added a header with the usual ListView method.
@erist I don't know if you're getting the same error. You didn't post a stack trace.
@hopesenddreams have you founded a solution for this issue ?
The class survives for a little while, but The HeaderView eventually kills it if you scroll and/or update for long enough.
FATAL EXCEPTION: main E Process: com.my.package.name, PID: 23030 E java.lang.IndexOutOfBoundsException: Invalid index 28, size is 1 E at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) E at java.util.ArrayList.get(ArrayList.java:308) E at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:225) E at android.widget.AbsListView.obtainView(AbsListView.java:2283) E at android.widget.ListView.makeAndAddView(ListView.java:1790) E at android.widget.ListView.fillDown(ListView.java:691) E at android.widget.ListView.fillGap(ListView.java:655) E at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5423) E at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4534) E at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) E at android.view.Choreographer.doCallbacks(Choreographer.java:574) E at android.view.Choreographer.doFrame(Choreographer.java:543) E at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) E at android.os.Handler.handleCallback(Handler.java:733) E at android.os.Handler.dispatchMessage(Handler.java:95) E at android.os.Looper.loop(Looper.java:136) E at android.app.ActivityThread.main(ActivityThread.java:5118) E at java.lang.reflect.Method.invokeNative(Native Method) E at java.lang.reflect.Method.invoke(Method.java:515) E at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) E at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606) E at dalvik.system.NativeStart.main(Native Method)
Another crash I get less often, I think this may also be related...
java.lang.NullPointerException E at android.widget.AbsListView.obtainView(AbsListView.java:2308) E at android.widget.ListView.makeAndAddView(ListView.java:1790) E at android.widget.ListView.fillDown(ListView.java:691) E at android.widget.ListView.fillGap(ListView.java:655) E at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5423) E at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4534) E at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) E at android.view.Choreographer.doCallbacks(Choreographer.java:574) E at android.view.Choreographer.doFrame(Choreographer.java:543) E at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) E at android.os.Handler.handleCallback(Handler.java:733) E at android.os.Handler.dispatchMessage(Handler.java:95) E at android.os.Looper.loop(Looper.java:136) E at android.app.ActivityThread.main(ActivityThread.java:5118) E at java.lang.reflect.Method.invokeNative(Native Method) E at java.lang.reflect.Method.invoke(Method.java:515) E at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) E at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606) E at dalvik.system.NativeStart.main(Native Method)