问题:Called attach on a child which is not detached: ViewHolder#出现问题的原因

经过google后发现,出现该问题的原因是由于recyclerView自带动画,当动画结束的时候,recyclerView会再次回收item,我们也因此可以重用item,而恰恰的是,我们在动画还没结束的时候,就视图重用item,结果就GG了。一下是谷歌的结果:[图片上传中。。。(1)]
相关链接#11

解决方法

我们可以把recyclerView的默认动画关了,两种解决方案:

  • 重写ItemAnimator并对RecyclerView进行设置
  • 设置ItemAnimator的动画时间

我选择了第二种

//mBinding.recyclerView.getItemAnimator().setAddDuration(0);
//mBinding.recyclerView.getItemAnimator().setChangeDuration(0);
//mBinding.recyclerView.getItemAnimator().setMoveDuration(0);
//mBinding.recyclerView.getItemAnimator().setRemoveDuration(0);
((SimpleItemAnimator)

作者:cwenhui
链接:http://www.jianshu.com/p/cbdf9a63c491
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

Called attach on a child which is not detached的更多相关文章

  1. java.lang.IllegalArgumentException: Called attach on a child which is not detached: ViewHolder

    转载请标明出处,维权必究:https://www.cnblogs.com/tangZH/p/10116298.html 在项目过程中出现了上述错误. 会出现这样的错误是在我使用: notifyItem ...

  2. 孟老板 Paging3 (一) 入门

    BaseAdapter系列 ListAdapter系列 Paging3 (一) 入门 Paging3 (二) 结合 Room Paging3 (一)  入门 前言: 官方分页工具,  确实香.   但 ...

  3. 用 set follow-fork-mode child即可。这是一个 gdb 命令,其目的是告诉 gdb 在目标应用调用fork之后接着调试子进程而不是父进程,因为在 Linux 中fork系统调用成功会返回两次,一次在父进程,一次在子进程

    GDB的那些奇淫技巧 evilpan 收录于 Security  2020-09-13  约 5433 字   预计阅读 11 分钟  709 次阅读  gdb也用了好几年了,虽然称不上骨灰级玩家,但 ...

  4. Flutter 让你的Dialog脱胎换骨吧!(Attach,Dialog,Loading,Toast)

    前言 Q:你一生中闻过最臭的东西,是什么? A:我那早已腐烂的梦. 兄弟萌!!!我又来了! 这次,我能自信的对大家说:我终于给大家带了一个,能真正帮助大家解决诸多坑比场景的pub包! 将之前的flut ...

  5. [转]GDB

    gdb调试coredump文件 gcc -g main.c //在目标文件加入源代码的信息 gdb a.out (gdb) start //开始调试 (gdb) n //一条一条执行 (gdb) st ...

  6. https://sourceware.org/gdb/onlinedocs/gdb/Forks.html

    https://sourceware.org/gdb/onlinedocs/gdb/Forks.html Next: Checkpoint/Restart, Previous: Threads, Up ...

  7. RenderBox使用说明书&原理浅析

    本文基于1.12.13+hotfix.8版本源码分析. 0.目录 一.RenderBox的用法 1.RenderBox的使用基本流程 2.RenderObjectWidget 3.非容器控件的hitT ...

  8. entity cannot be tracked

    背景:EF Core项目中使用InMemory作为数据库提供程序,编写单元测试. 报错:“The instance of entity type 'Movie' cannot be tracked b ...

  9. [20190409]pre_page_sga=true与连接缓慢的问题.txt

    [20190409]pre_page_sga=true与连接缓慢的问题.txt --//曾经遇到11g下设置pre_page_sga=true启动缓慢的问题(没有使用hugepages).--//链接 ...

随机推荐

  1. 一次偶遇 IOException

    今天遇到了个挺有意思的事情,为了实现上传头像的功能,这是需要实现的功能,项目在本地跑起来且在本地 服务器(tomcat)也实现了头像上传,并把头像路径存入数据库,但是却在上传到线上服务器的时候死活存不 ...

  2. 基于html实现一个todolist待办事项

    index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...

  3. Jmeter关联,正则表达式提取器使用1

    Jmeter关联,正则表达式提取器使用    一.Jmeter关联的方式: Jmeter中关联可以在需要获取数据的请求上 右键-->后置处理器 选择需要的关联方式,如下图有很多种方法可以提取动态 ...

  4. BNUOJ 26229 Red/Blue Spanning Tree

    Red/Blue Spanning Tree Time Limit: 2000ms Memory Limit: 131072KB This problem will be judged on HDU. ...

  5. codevs1154 能量项链

    题目描述 Description 在Mars星球上,每个Mars人都随身佩带着一串能量项链.在项链上有N颗能量珠.能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某个正整数.并且,对于相邻的两颗珠子 ...

  6. CALayer之 customizing timing of an animation

    customizing timing of an animation Timing is an important part of animations, and with Core Animatio ...

  7. ACM组队安排-——杭电校赛(递推)

    #include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #in ...

  8. java.lang.RuntimeException: JPedal Trial has now expired

    具体提示: java.lang.RuntimeException: JPedal Trial has now expired jpedal-server-trial.jar jar包过期了,jpeda ...

  9. 【python自制】让大白成为你的个人助手!

    我做这个软件就是要让卖萌进行究竟! 官方站点:http://www.jackeriss.com/companions.htm GitHub:https://github.com/Jackeriss/C ...

  10. Good Zookeeper Tutorial with Java client

    参考: https://stackoverflow.com/questions/33524537/good-zookeeper-tutorial-with-java-client I was tryi ...