RecyclerView 是 Android 的标准组件,用于高效显示可滚动的数据列表。它"回收" views(在滚动时重新使用它们),而不是为每个 item 创建一个 view——这对长列表的性能至关重要。
RecyclerView 为什么重要(回收的概念)
Displaying a long list naively (a view per item) is WASTEFUL — thousands of items =
thousands of views = memory/performance problems.
RECYCLERVIEW reuses a small pool of views:
→ only views for VISIBLE items exist; as you scroll, off-screen views are RECYCLED
(re-bound with new data) for newly-visible items
→ constant memory regardless of list size → smooth, efficient scrolling
→ This recycling is the key to performant lists.
关键部分
ADAPTER → binds your DATA to views (creates view holders, binds data to them)
VIEWHOLDER → holds the views for one list item (caches view references — avoids repeated
lookups; part of the efficiency)
LAYOUT MANAGER → arranges items (LinearLayoutManager = list, GridLayoutManager = grid,
StaggeredGrid)
