Android分页库getItem raisesIllegalArgumentException

时间:2018-06-24 20:47:02

标签: android android-architecture-components android-jetpack

我将Architecture component's paging library与RecyclerView一起使用

当我覆盖getItemViewType时

getItem(position)

在“ OnBindViewHolder”中调用相同的功能就像一个魅力

这是堆栈跟踪

  

java.lang.IllegalArgumentException:仅当最后一页只有一个时,页面大小才能更改           在android.arch.paging.PagedStorage.allocatePlaceholders(PagedStorage.java:404)           在android.arch.paging.TiledPagedList.loadAroundInternal(TiledPagedList.java:156)           在android.arch.paging.PagedList.loadAround(PagedList.java:398)           在android.arch.paging.AsyncPagedListDiffer.getItem(AsyncPagedListDiffer.java:201)           在android.arch.paging.PagedListAdapter.getItem(PagedListAdapter.java:156)           在me.ekhaled1619.redditur.ui.PostsAdapter.getItemViewType(PostsAdapter.kt:75)           在android.support.v7.widget.RecyclerView $ Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5880)           在android.support.v7.widget.RecyclerView $ Recycler.getViewForPosition(RecyclerView.java:5812)           在android.support.v7.widget.RecyclerView $ Recycler.getViewForPosition(RecyclerView.java:5808)           在android.support.v7.widget.LinearLayoutManager $ LayoutState.next(LinearLayoutManager.java:2230)           在android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)           在android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)           在android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)           在android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3878)           在android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3595)           在android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:4148)           在android.view.View.layout(View.java:17551)           在android.view.ViewGroup.layout(ViewGroup.java:5614)           在android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:625)           在android.view.View.layout(View.java:17551)           在android.view.ViewGroup.layout(ViewGroup.java:5614)           在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)           在android.widget.FrameLayout.onLayout(FrameLayout.java:261)           在android.view.View.layout(View.java:17551)           在android.view.ViewGroup.layout(ViewGroup.java:5614)           在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)           在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)           在android.widget.LinearLayout.onLayout(LinearLayout.java:1494)           在android.view.View.layout(View.java:17551)           在android.view.ViewGroup.layout(ViewGroup.java:5614)           在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)           在android.widget.FrameLayout.onLayout(FrameLayout.java:261)           在android.view.View.layout(View.java:17551)           在android.view.ViewGroup.layout(ViewGroup.java:5614)           在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)           在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)           在android.widget.LinearLayout.onLayout(LinearLayout.java:1494)           在android.view.View.layout(View.java:17551)           在android.view.ViewGroup.layout(ViewGroup.java:5614)           在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)           在android.widget.FrameLayout.onLayout(FrameLayout.java:261)           在com.android.internal.policy.DecorView.onLayout(DecorView.java:727)           在android.view.View.layout(View.java:17551)           在android.view.ViewGroup.layout(ViewGroup.java:5614)           在android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2379)           在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2106)           在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1283)           在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6358)           在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:873)           在android.view.Choreographer.doCallbacks(Choreographer.java:685)           在android.view.Choreographer.doFrame(Choreographer.java:621)           在android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:859)           在android.os.Handler.handleCallback(Handler.java:754)           在android.os.Handler.dispatchMessage(Handler.java:95)           在android.os.Looper.loop(Looper.java:165)           在android.app.ActivityThread.main(ActivityThread.java:6365)   2018-06-24 22:37:11.892 26173-26173 / me.ekhaled1619.redditur E / AndroidRuntime:at java.lang.reflect.Method.invoke(本机方法)           在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:883)           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)

0 个答案:

没有答案