4

我已经用RecyclerView. 当用户点击底部时,我正在添加null对象以显示进度AsyncTask onPreExecute并通知适配器项已插入。这段代码我已经使用了一段时间了。最近我从23.0.3 to 24.2.1. 从那时起,当我在列表底部时遇到异常。

Cannot call this method in a scroll callback. Scroll callbacks might be run during a measure & layout pass where you cannot change the RecyclerView data. Any method call that might change the structure of the RecyclerView or the adapter contents should be postponed to the next frame.
java.lang.IllegalStateException: 
at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2403)
at android.support.v7.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeInserted(RecyclerView.java:4634)
at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyItemRangeInserted(RecyclerView.java:10472)
at android.support.v7.widget.RecyclerView$Adapter.notifyItemInserted(RecyclerView.java:6214)
at com.test.film.buzz.BuzzFeedsFragment$5.onPreExecute(BuzzFeedsFragment.java:229)
at com.test.utils.ParallelAsyncTask.executeOnExecutor(ParallelAsyncTask.java:595)
at com.test.utils.ParallelAsyncTask.execute(ParallelAsyncTask.java:543)
at com.test.film.buzz.BuzzFeedsFragment.onLoadMore(BuzzFeedsFragment.java:258)
at com.test.film.buzz.BuzzFeedsFragment$3.onScrolled(BuzzFeedsFragment.java:177)
at android.support.v7.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:4305)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4463)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
at android.view.Choreographer.doCallbacks(Choreographer.java:683)
at android.view.Choreographer.doFrame(Choreographer.java:616)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)                                                   
4

0 回答 0