RecyclerView , IllegalStateException: Cannot call this method while RecyclerView is computing a layo
来源:互联网 发布:在手机淘宝怎么卖东西 编辑:程序博客网 时间:2024/05/16 07:13
RecyclerView , IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
在使用recycleview的时候,里面的每一项都有一个seekbar的子控件,当同时滑动几个seekbar的时候就有可能导致app crash掉,报这个错误.原因是我再滑动某个seekbar的时候,其他seekbar也要跟着动态更新.而更新的时候需要用到adapter的notifydatachange,所以我在seekbar的滑动结束之后开放接口出去,让adapter那边更新.就是在同时滑动几个seekbar的时候也触发来 recycleview的滑动事件,这时候就会报recycleview在计算layout或者滑动的时候不能调用notifydatachange的错误
解决方法:
在滑动或者计算layout的时候不刷新数据:
判断是否正在滑动的方法是getScrollState(),如果它等于RecyclerView.SCROLL_STATE_IDLE说明不在滑动,判断有没有在计算layout的方法是isComputingLayout(),取否就可以得到不在计算的时候,通过这两个条件来决定是否刷新数据
2 0
- RecyclerView , IllegalStateException: Cannot call this method while RecyclerView is computing a layo
- Cannot call this method while RecyclerView is computing a layout or scrolling
- 关于cannot call this method while recyclerview is computing a layout or scrollin
- 使用RecyclerView中引发 java.lang.IllegalStateException: Cannot call this method while RecyclerView is com
- RecyclerView notifyDataSetChanged() 报IllegalStateException解决
- RecyclerView
- RecyclerView
- RecyclerView
- RecyclerView
- RecyclerView
- RecyclerView
- RecyclerView
- RecyclerView
- RecyclerView
- RecyclerView
- RecyclerView
- RecyclerView
- RecyclerView
- 如果flip,y方向的offset不能太大
- 对java List中的对象进行排序
- Android Studio很实用的调试技巧
- perl lwp 响应信息
- SNMP 原理与实战详解
- RecyclerView , IllegalStateException: Cannot call this method while RecyclerView is computing a layo
- MagicalRecord操作CoreData小示例
- 视频编码名词参数解释
- 学习Android从0开始之开发工具篇-Android studio详解
- 挤死collideWith: function(other, axis) { if (other.touches(this)) { other.kill(); } }
- 主程序访问线程的临时变量
- Android Studio导入eclipse项目
- LIO -SCSI target
- SQLite