RecyclerView主场迎战的ListView [英] RecyclerView vs. ListView
问题描述
这是Android开发者:
From android developer :
的RecyclerView插件是一种更先进的和柔性版 ListView控件。
The RecyclerView widget is a more advanced and flexible version of ListView.
好吧,这听起来很酷。但是我真的搞不清他们的区别时,我看到了一个例子图:
Okay, it sounds cool. But i really confuse about their difference when i saw an example picture :
以上可以通过的ListView轻松创建图片
自定义适配器。
The picture above can be easily created by ListView
with custom adapter.
那么,你怎么看这件事?什么是最适合与 RecyclerView
?
So, what do you think about this? What is the situation that fit best with RecyclerView
?
推荐答案
Android的创建RecycleView作为一个ListView改善,所以是的,你可以创建连接列表ListView控件,但使用RecyclerView让我们很容易:
Android created RecycleView as a ListView improvement, so yes, you could create attached list with ListView control, but using RecyclerView makes easier to:
1)再利用细胞的同时滚动向上/向下 - 这是可能的实施视图持有人在ListView适配器,但它是一个可选的事情,而在RecycleView这是写作的默认方式适配器。
1.) Reuse cells while scrolling up/down - this is possible with implementing View Holder in the listView adapter, but it was an optional thing, while in the RecycleView it's the default way of writing adapter.
2)者分离列表,它的容器 - 所以你可以把列表项容易在运行时在不同的容器(LinearLayout中,网格布局)与设定的布局管理
2.) Decouple list from it's container - so you can put list items easily at run time in the different containers (linearLayout, gridLayout) with setting LayoutManager
编辑 - 例如:
mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
//or
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));*
3)动画常见的列表操作 - 动画解耦和委托为 ItemAnimator 。
3.) Animate common list actions - Animations are decoupled and delegated to ItemAnimator.
还有更多关于RecycleView,但我认为这些都是要点。
There is more about RecycleView but I think those are the main points.
所以,最后RecycleView更灵活的控制来处理列表数据下面的担忧代表团模式和树叶本身只有一个任务 - 回收项目
So, to conclude RecycleView is more flexible control for handling "list data" that follows patterns of delegation of concerns and leaves for itself only one task - recycling items.
这篇关于RecyclerView主场迎战的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!