什么是比较的ListView RecyclerView优势? [英] What are RecyclerView advantages compared to ListView?

查看:848
本文介绍了什么是比较的ListView RecyclerView优势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是用RecyclerView开始,我已经看到了它缺乏很多像页眉,页脚,分频器,列表选择功能,现在我对使用它,而不是ListView的第二个想法。

I just started using RecyclerView and I've seen it lack in a lot of features like header, footer, divider, list selector, now I have second thoughts about using it instead of ListView.

有哪些优势和比较的ListView RecyclerView的缺点是什么?
它可以比ListView的处理更复杂的看法?

What are the advantages and disadvantages of RecyclerView compared to ListView? Can it handle more complex views than ListView ?

我一直在使用的ListView至今并不在少数,是时候切换到RecyclerView还是太早了吧?

I've been using ListView till now and for a few, is it time to switch to RecyclerView or is it too soon now?

推荐答案

通过Android的棒棒糖,在 RecyclerView 作出了正式的方式来临。该RecyclerView得多的强大,灵活和在ListView的一个重大改进。我会尽量给你一个详细的洞察它。

With the advent of Android Lollipop, the RecyclerView made its way officially. The RecyclerView is much more powerful, flexible and a major enhancement over ListView. I will try to give you a detailed insight into it.

优点

1)ViewHolder模式

在一个ListView,建议使用ViewHolder模式,但它从来就不是一个强迫。在RecyclerView的情况下,这是必须使用RecyclerView.ViewHolder类。这是在ListView和RecyclerView之间的主要区别之一。

In a ListView, it was recommended to use the ViewHolder pattern but it was never a compulsion. In case of RecyclerView, this is mandatory using the RecyclerView.ViewHolder class. This is one of the major differences between the ListView and the RecyclerView.

这使事情有点在RecyclerView更复杂,但很多问题是我们面临的ListView中得到有效解决。

It makes things a bit more complex in RecyclerView but a lot of problems that we faced in the ListView are solved efficiently.

2)的LayoutManager

这是带到另一个RecyclerView大规模提升。在一个ListView,视唯一可用的类型是垂直的ListView。还有就是即使实施水平的ListView没有正式的办法。

This is another massive enhancement brought to the RecyclerView. In a ListView, the only type of view available is the vertical ListView. There is no official way to even implement a horizontal ListView.

现在使用RecyclerView,我们可以有一个

Now using a RecyclerView, we can have a

我)<一个href=\"https://developer.android.com/reference/android/support/v7/widget/LinearLayoutManager.html\">LinearLayoutManager - 支持垂直和水平列表,

i) LinearLayoutManager - which supports both vertical and horizontal lists,

ⅱ)<一href=\"https://developer.android.com/reference/android/support/v7/widget/StaggeredGridLayoutManager.html\">StaggeredLayoutManager - 支持像Pinterest的交错名单,

ii) StaggeredLayoutManager - which supports Pinterest like staggered lists,

ⅲ)<一href=\"https://developer.android.com/reference/android/support/v7/widget/GridLayoutManager.html\">GridLayoutManager - 支持显示网格在画廊看到的应用程序

iii) GridLayoutManager - which supports displaying grids as seen in Gallery apps.

和最好的事情是我们可以做所有这些动态的,因为我们想要的。

And the best thing is that we can do all these dynamically as we want.

3)项目动画

列表视图都缺乏支持好动画,但RecyclerView带来了一个全新的层面给它。使用RecyclerView.ItemAnimator类,动画的看法变得如此多的方便和直观。

ListViews are lacking in support of good animations, but the RecyclerView brings a whole new dimension to it. Using the RecyclerView.ItemAnimator class, animating the views becomes so much easy and intuitive.

4)项目装饰

在列表视图的情况下,如添加边框或隔板动态装饰物品并非易事。但在RecyclerView的,在<的情况下href=\"https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ItemDecoration.html\">RecyclerView.ItemDecorator类提供巨大的控制权交给开发商,但做事情有点耗费更多的时间和复杂的。

In case of ListViews, dynamically decorating items like adding borders or dividers was never easy. But in case of RecyclerView, the RecyclerView.ItemDecorator class gives huge control to the developers but makes things a bit more time consuming and complex.

5)OnItemTouchListener

截取项目点击了一个ListView很简单,这要归功于它的<一个href=\"http://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener.html\">AdapterView.OnItemClickListener接口。但RecyclerView赋予更多的权力和控制它的开发由<一个href=\"https://developer.android.com/reference/android/support/v7/widget/RecyclerView.OnItemTouchListener.html\">RecyclerView.OnItemTouchListener但复杂的事情有点为开发。

Intercepting item clicks on a ListView was simple, thanks to its AdapterView.OnItemClickListener interface. But the RecyclerView gives much more power and control to its developers by the RecyclerView.OnItemTouchListener but it complicates things a bit for the developer.

劣势

我),这是比列表视图更复杂。

i) It is way more complex than a list view.

二)它可能需要大量的时间对于一个初学者全面理解一个RecyclerView。

ii) It can take a lot of time for a beginner to understand a RecyclerView fully.

III),它可以让不必要的编码的生活困难。

iii) It can unnecessarily make your coding life difficult.

四)你需要花费更多的时间与它比你需要一个ListView

iv) You will need to spend much more time with it than you ever needed for a ListView

这篇关于什么是比较的ListView RecyclerView优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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