What's the enhancement of RecyclerView over ListView?

前端 未结 3 1773
长发绾君心
长发绾君心 2021-02-13 18:04

RecyclerView is added into v7 support library since Android API 22 officially. And many people said that it is a enhancement over ListView

3条回答
  •  终归单人心
    2021-02-13 18:48

    1. View Holders

      RecylerView by the use of RecyclerView.ViewHolder class. This is one of the major differences in RecyclerView and ListView. When implementing a RecyclerView this class is used to define a ViewHolder object which is used by the adapter to bind ViewHolder with a position

    2. Layout Manager

      support for horizontal collections as well. In-fact it supports multiple types of lists. To support multiple types of lists it uses RecyclerView.LayoutManager class. This is something new that ListView does not have. RecyclerView supports three types of predefined Layout Managers: LinearLayoutManager – This is the most commonly used layout manager in case of RecyclerView. Through this, we can create both horizontal and vertical scroll lists. StaggeredGridLayoutManager – Through this layout manager, we can create staggered lists. Just like the Pinterest screen. GridLayoutManager– This layout manager can be used to display grids, like any picture gallery.

    3. Item Animator

      RecyclerView has RecyclerView.ItemAnimator class for handling animations. Through this class custom animations can be defined for item addition, deletion and move events. Also it provides a DefaultItemAnimator, in case you don’t need any customizations.

    4. Adapter

      In RecyclerView.Adapter as of now we have to make a custom implementation to supply data to the adapter. Just like a BaseAdapter does for ListViews.

    Source: http://www.truiton.com/2015/03/android-recyclerview-vs-listview-comparison/

提交回复
热议问题