The difference between ListView and RecycleView

Principle of cache

The cache mechanism of ListView and RecyclerView is roughly similar in principle. Items removed from the screen will be recycled into the cache, and items entered into the screen will be retrieved from the cache first.

Different levels of

  1. ListView(two-level cache) : ListView has mActiveViews and mScrapViews
  2. RecycleView is a four-level cache: mAttachedScrap; MCachedViews, mViewCacheExtension (not directly used, customized), mRecyclerPool

The contents of the cache are different

  1. ListView caches views
  2. RecyclerView recyclerView. ViewHolder (View + ViewHolder) + flag (createView)

RecycleView supports partial refresh

The main difference between the two is the cache logic when the data source changes. ListView moves all mActiveViews to the mScrapViews recycle cache. But RecyclerView is more flexible to modify the symbol bit of each View, distinguish whether to re-bindView