简体   繁体   English

Recyclerview Android上的动画

[英]Animation on Recyclerview Android


I was going through this thread on this topic : RecyclerView Animation on Item Click 我正在研究有关此主题的线程: 物品点击上的RecyclerView动画

But I have one question on the technique used. 但是我对使用的技术有一个疑问。 I tried implementing it based on solution above. 我尝试根据上述解决方案实施它。 Although the approach seems to work in the current view of my recyclerview. 虽然这种方法似乎在我的recyclerview的当前视图中有效。 But as soon as i scroll further to Right (in my case its a Horizontal Recyclerview), i still see the view being expanded since the views are being recycled and the isExpanded value is still true for them. 但是,只要我进一步滚动到Right(在我的情况下是Horizo​​ntal Recyclerview),由于视图被回收并且isExpanded值仍然适用,我仍然看到视图正在扩展。 I was thinking shouldn't the isExpanded property be at the data being displayed, so that we don't keep the same state of the reused view ? 我在想isExpanded属性是否不应该显示在数据上,这样我们就不会保持重用视图的相同状态?

Curious to know, how does RecyclerView behaves when you scroll it to the next page. 奇怪的是,当您将RecyclerView滚动到下一页时,它的行为如何。

Thanks, 谢谢,

Ok, basically you need to check each item "state" and prepare the recycled viewholder for the new item to bind. 好的,基本上,您需要检查每个项目的“状态”,并为新项目绑定准备回收的Viewholder。

Please have a look at my ExampleAdapter (in onBindViewHolder() ) in my FlexibleAdapter, where you can also find basic click and long click listener already implemented as example. 请查看我的FlexibleAdapter中的ExampleAdapter (在onBindViewHolder() ),在这里您还可以找到已经作为示例实现的基本click和long click侦听器。

Feel free to ask questions. 随意问的问题。

Recently I've improved and created a FlexibleAdapter pattern for all RecyclerView. 最近,我改进并为所有RecyclerView创建了FlexibleAdapter模式。 Very simple to use, just copy 2 classes in your common files + some xml in order to enable the selection (Single/Multi) as it was for ListView. 使用非常简单,只需将2个类复制到您的公共文件中,再复制一些xml,即可启用对ListView的选择(单/多)。

Please have a look at the description and full working example: https://github.com/davideas/FlexibleAdapter 请查看说明和完整的工作示例: https : //github.com/davideas/FlexibleAdapter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM