我正在使用Recyclerview显示图像和其他内容的列表。当recyclerview加载并快速滚动时,它崩溃了。
当我调试时,我可以看到
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
...
viewHolder.getItemId() // this returns -1, sometimes
我怀疑没有完全创建Recyclerview Adapter视图,对此有什么建议吗?
由于您尚未共享代码,我们不确定您的情况如何,但让我分享一个可能与您有关的情况。RecyclerView崩溃的可能情况:
1. This crash might be caused by the fact that the setViewHolder and onBind
methods are being called while your list(used by the adapter) is being updated, but notifyDataSetChanged() hasn't been called.
2. This problem may caused when android start dealing with bitmaps. the main
reason is lack of memory space and also, garbage collector cannot free some
space.
3. If you using image , please confirm the image size because the size may
cause this problem. Some case recyclerview was not able to hold the images
with big resolution.
4. Double check if you are using all the data loading process in ( main/UI
thread ), it my testing Looper.getMainLooper() == Looper.myLooper().
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。