我应该将应用程序中现有的Listview更改为RecyclerView吗? [英] Should I change the existing Listview in my app to RecyclerView?

查看:314
本文介绍了我应该将应用程序中现有的Listview更改为RecyclerView吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我的应用程序中现有的Listview转换为RecyclerView是否有任何优势? 另外,我什么时候应该使用RecyclerView?

Is there any advantages of converting the existing Listview in my app to RecyclerView?? Also when should I be using RecyclerView??

推荐答案

这是一个很难回答的问题.首先:将RecyclerView视为AdapterViews的后继者,它进行了很多有用的改进,尤其是在每个项目的动画领域.实际上,这也是文档所说的:

That's a tough question to answer. First of all: Think of the RecyclerView as the successor of the AdapterViews which comes with alot of useful improvement especially in the fields of animations for each item. Actually that's also what the Docs say:

RecyclerView是ListView的更高级,更灵活的版本.这 小部件是用于容纳大量视图的容器,这些视图可以回收和使用 滚动非常有效.您可以使用RecyclerView小部件 列出的元素动态变化.

RecyclerView is a more advanced and flexible version of ListView. This widget is a container for large sets of views that can be recycled and scrolled very efficiently. Use the RecyclerView widget when you have lists with elements that change dynamically.

您还可以灵活地定义自定义布局管理器和 此小部件的动画.

You also have the flexibility to define custom layout managers and animations for this widget.

因此,将来我们可能不再使用ListViews.此外,从列表中添加或删除项目时,RecyclerView不需要"notifyDataSetChanged()"之类的东西,这在性能上是一个巨大的改进.
如果您想通过说"ListView的更高级和更灵活的版本" 进一步了解Google的含义,建议您阅读此Blog-Post

So in the future we'll probably don't use ListViews anymore. Furthermore the RecyclerView doesn't need anything like "notifyDataSetChanged()" when an item is added or deleted from your List, which is a huge improvement performance-wise.
If you wanna know more what Google means by saying "more advanced and flexible version of ListView" I'd recommend you to read this Blog-Post A First Glance at Android’s RecyclerView.

但是要明确回答您的问题:

But to answer your questions explicity:

将我的应用程序中现有的Listview转换为RecyclerView有什么优势?
是的.如前所述,RecyclerView更加灵活,并且附带了方便的动画,没有任何费用. (就您自己而言)

Is there any advantages of converting the existing Listview in my app to RecyclerView?
Yes. As already said the RecyclerView is much more flexible and comes with handy animations at no cost. (In terms of doing this on your own)

我什么时候应该使用RecyclerView?
在适合使用ListView的任何地方,也都可以使用RecyclerView.

When should I be using RecyclerView?
Everywhere where a ListView is appropriate a RecyclerView is as well.

还有一个附加问题:
是否有必要从ListView切换到RecyclerView?
此刻绝对不行!您必须考虑到RecyclerView目前还不是最终版本.因此,在不久的将来可能会有一些更改,错误修复和新功能. (作为一个错误的示例:clipToPadding在atm上不起作用.幸运的是,它
已被举报)

And an additional question:
Is it necessary to switch from ListView to RecyclerView?
At the moment absolutely not! You have to consider that the RecyclerView isn't final at this point. So there may be some changes, bug-fixes and new features in the near future. (As an example for a bug: clipToPadding doesn't work atm. Luckily it has been reported already)

这篇关于我应该将应用程序中现有的Listview更改为RecyclerView吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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