Animation on Recyclerview Android

≯℡__Kan透↙ 提交于 2019-12-12 04:50:24

问题



I was going through this thread on this topic : RecyclerView Animation on Item Click

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. 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. 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 ?

Curious to know, how does RecyclerView behaves when you scroll it to the next page.

Thanks,


回答1:


Ok, basically you need to check each item "state" and prepare the recycled viewholder for the new item to bind.

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.

Feel free to ask questions.

Recently I've improved and created a FlexibleAdapter pattern for all RecyclerView. 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.

Please have a look at the description and full working example: https://github.com/davideas/FlexibleAdapter



来源:https://stackoverflow.com/questions/28133819/animation-on-recyclerview-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!