Explain in detail the pit encountered by EditText using refresh in recyclerview item

Due to the needs of the work project, the evaluation function should be added after the purchase of goods, so I imitated the evaluation effect drawing of Taobao as the evaluation effect drawing in my project. However, I encountered a big pit in the development, that is, after dynamically adding photos, When refreshing the adapter, the text in EditText in. Item is disordered. Finally, the bug is found to be caused by the following code

Finally, I found it on the Internet for a long time to know that the reuse of recyclerview entries leads to the redrawing of listening events, so we only need to remove the reuse of recyclerview to perfectly solve this problem. However, we know that recyclerview comes with reuse. How to remove reuse? You only need to add the following code to onbindviewholder (evaluateholder, int position) to forcibly disable the reuse of recyclerview. There are two solutions

The first is to forcibly disable the reuse of recyclerview:

The second method is to solve the reuse of recyclerview through the settag () method of view. The code is as follows:

These two methods can solve the problem, but the method is only suitable for the situation with fewer items. If you have more items, it is not suitable. I hope the pit I stepped on can help you and make progress together. Thank you!!!!

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>