我在 RecyclerView 里面做了 RecyclerView。有ClassCastException在 onBindViewHolder。错误信息在这里。 java.lang.ClassCastException: com.work.hany.playinseoul.main.adapter.MainRecyclerViewAdapter$TourViewHolder$TourSectionItemsAdapter$TourItemViewHolder cannot be cast to com.work.hany.playinseoul.main.adapter.MainRecyclerViewAdapter$CategoryViewHolder$CategoryItemViewHolder at com.work.hany.playinseoul.main.adapter.MainRecyclerViewAdapter$CategoryViewHolder$CategoryHorizontalAdapter.onBindViewHolder(MainRecyclerViewAdapter.java:216) at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6673) at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6714)但我无法赶上ClassCastException的TourSectionItemsAdapter onBindViewHolder。因此,我无法在 TourSectionItemsAdapter onBindViewHolder 上检查持有人类型。只有我在 MainRecyclerViewAdapter onBindViewHolder 上捕获了 ClassCastException。但是 MainRecyclerViewAdapter onBindViewHolder 持有人类型是相同的投 hodler 类。检查屏幕截图。
2 回答
慕侠2389804
TA贡献1719条经验 获得超6个赞
也许为时已晚,但对于功能读者来说,只需像这样定义 viewPool
private val viewPool = RecyclerView.RecycledViewPool()
添加回答
举报
0/150
提交
取消