扩展列表RecyclerView? [英] Expandable list with RecyclerView?

查看:206
本文介绍了扩展列表RecyclerView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是可以使用新的RecyclerView扩展列表中的项目?像ExpandableListView?

It's possible to use expandable list items with new RecyclerView? Like ExpandableListView?

推荐答案

这是简单的事与股票布局管理,这一切都取决于你如何管理你的适配器。

This is simple to do with the stock LayoutManagers, it all depends on how you manage your adapter.

当你想扩展部分,您只需在头后面新的项目添加到您的适配器。记得打电话notifyItemRangeInserted当你做到这一点。要折叠部分,您只需删除相关项目,并调用notifyItemRangeRemoved()。对于适当通知的任何数据的变化,回收视图将动画的看法。当添加的物品,区域内盛新的物品制成,与衰落中的新项目。拆除是相反的。所有你需要做的除了适配器东西是风格你的意见转达逻辑结构给用户。

When you want to expand a section you just add new items to your adapter after the header. Remember to call notifyItemRangeInserted when you do this. To collapse a section you simply remove the relevant items, and call notifyItemRangeRemoved(). For any data changes that are appropriately notified, the recycler view will animate the views. When adding items, an area to be filled with the new items is made, with the new items fading in. Removal is the opposite. All you need to do besides the adapter stuff is to style your views to convey the logical structure to the user.

更新:瑞安布鲁克斯现在已经写了<一href="https://www.bignerdranch.com/blog/expand-a-recyclerview-in-four-steps/?utm_source=Android+Weekly&utm_campaign=8f0cc3ff1f-Android_Weekly_165&utm_medium=email&utm_term=0_4eb677ad19-8f0cc3ff1f-337834121">article如何做到这一点。

Update: Ryan Brooks has now written an article on how to do this.

这篇关于扩展列表RecyclerView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆