美文网首页
BUG-Android 4. Bug 汇总

BUG-Android 4. Bug 汇总

作者: KYM1988 | 来源:发表于2019-11-12 09:31 被阅读0次

1. 异常导致崩溃:java.lang.IndexOutOfBoundsException: Invalid item position 0(0). Item count:0 PageRecyelerView.PageRecyclerView{b2c437c VFED..... ......I. 0,0-0,0 #7f070062 app:id/cusom_swipe_view}, adapter:PageRecyelerView.PageRecyclerView$PageAdapter@c50b405, layout:PageRecyelerView.AutoGridLayoutManager@6145c5a, context:PageRecyelerView.pageMainActivity@71cf016

问题点:

@Override

public void onMeasure(RecyclerView.Recycler recycler,  RecyclerView.State state, int widthSpec, int heightSpec) {

if (measuredHeight <=0) {

View view = recycler.getViewForPosition(0);

  if (view !=null) {

            measureChild(view, widthSpec, heightSpec);

            measuredWidth = View.MeasureSpec.getSize(widthSpec);

            measuredHeight = view.getMeasuredHeight() * getSpanCount();

        }

}

setMeasuredDimension(measuredWidth, measuredHeight);

}

解决方法:

//获取count判断,必须要有

int count = state.getItemCount();

if (count >0) {

if (measuredHeight <=0) {

View view = recycler.getViewForPosition(0);

        measureChild(view, widthSpec, heightSpec);

        measuredWidth = View.MeasureSpec.getSize(widthSpec);

        measuredHeight = view.getMeasuredHeight() * getSpanCount();

    }

setMeasuredDimension(measuredWidth, measuredHeight);

}else {

super.onMeasure(recycler, state, widthSpec, heightSpec);

}

原档:https://blog.csdn.net/qq_26530191/article/details/83622434

相关文章

  • BUG-Android 4. Bug 汇总

    1.异常导致崩溃:java.lang.IndexOutOfBoundsException: Invalid ite...

  • bug汇总

    1111

  • bug汇总

    Hide status bar 如果旋转隐藏statasBar 那么在程序启动的开始 获取到的statubar高度...

  • BUG汇总

    echarts:div 默认 display:none,改为 display:block 时,echarts 无法...

  • Bug汇总

    autoResize 1 .只支持横线的felx布局,纵向的不行.2 .需要加个这个操作.container-in...

  • ios 10.3

    Xcode8 及iOS10适配问题汇总 上点干货,目前得知的一些bug解决汇总: iOS10相册相机闪退bug h...

  • Eat-Vue:日常记录1

    日常记录Vue中遇见的Bug和一些用法汇总:BUG:1、[Vue warn]: You are using the...

  • BUG汇总记录

    1、Could not successfully update network info during initi...

  • BUG汇总 1

    1.Unsupported Modules Detected: Compilation is not suppor...

  • 前端bug汇总

    div整体ahove不变色原因 设置div的背景色不变色是因为设置高度太小导致.应该去除height属性设置.

网友评论

      本文标题:BUG-Android 4. Bug 汇总

      本文链接:https://www.haomeiwen.com/subject/sglfictx.html