RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
RecyclerView索引溢出异常的解决方法-创新互联

使用RecyclerView过程中遇到异常:

成都创新互联公司专注于滦南企业网站建设,响应式网站开发,商城网站建设。滦南网站建设公司,为滦南等地区提供建站服务。全流程按需定制网站,专业设计,全程项目跟踪,成都创新互联公司专业和态度为您提供的服务

java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder


继承并重写LinearLayoutManager.onLayoutChildren()方法

class WrappedLinearLayoutManager : LinearLayoutManager {

  constructor(context: Context) : super(context)

  constructor(context: Context, orientation: Int, reverseLayout: Boolean) : super(context, orientation, reverseLayout)

  constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)

  override fun onLayoutChildren(recycler: RecyclerView.Recycler?, state: RecyclerView.State) {
    try {
      super.onLayoutChildren(recycler, state)
    } catch (e: IndexOutOfBoundsException) {
      e.printStackTrace()
    }
  }
}


网站标题:RecyclerView索引溢出异常的解决方法-创新互联
本文地址:http://scyingshan.cn/article/dhiioh.html