美文网首页android开发日常报错系列
RecyclerView.getChildAt(Position

RecyclerView.getChildAt(Position

作者: 蔡宝e | 来源:发表于2021-01-09 16:24 被阅读0次

转自RecyclerView.getChildAt(Position)空指针异常_laughing_lh的专栏-CSDN博客

获取RecyclerView的itemView不能用getChildAt(position,因为position大于当前屏幕展示view的个数时,通过getChildAt()方法获取view会报空指针异常,这个方法其实只能get到当前屏幕所展示的view

应该通过recycleview的LayoutManager去获取,recycleview.getLayoutManager().findViewByPosition()

相关文章

网友评论

    本文标题:RecyclerView.getChildAt(Position

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