Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

点击事件,在快速刷新列表的时候失效了。 #67

Closed
amosxb opened this issue Nov 5, 2021 · 6 comments
Closed

点击事件,在快速刷新列表的时候失效了。 #67

amosxb opened this issue Nov 5, 2021 · 6 comments

Comments

@amosxb
Copy link

amosxb commented Nov 5, 2021

No description provided.

@liangjingkanji
Copy link
Owner

什么叫快速刷新列表

@amosxb
Copy link
Author

amosxb commented Nov 5, 2021

image
一直调这个方法,

@liangjingkanji
Copy link
Owner

那是正常的,不清楚你为什么频繁调用,这对性能也是不好的,建议你用databinding刷新数据

@amosxb
Copy link
Author

amosxb commented Nov 6, 2021

在做蓝牙列表的时候需要不断的刷新列表,但是就会出现这种点击事件失效的情况。

@liangjingkanji
Copy link
Owner

位于刷新的Item会被重新设置ViewHolder, 而ViewHolder包含点击事件监听器

这里推荐两种解决办法

  1. 使用DataBinding去刷新数据而不是刷新Item
  2. 使用DiffUtils去只刷新需要刷新的Item而不是刷新全部

@liangjingkanji
Copy link
Owner

现在新增setDifferModels函数可以增量更新, 可以试试这个

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants