Compose 中的列表
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
探索 Compose 的延迟组件,这些组件可让您轻松显示项列表。
了解如何显示不同类型的项、实现固定标题,以及如何以编程方式控制滚动位置变化或对其做出响应。
要点
LazyColumn
API 是作为 DSL 构建的,与 Compose 中的其他布局不同。
- 使用
LazyColumn
显示屏幕上可见的项。
- 使用
items()
函数传递项。lambda 定义了每个项的内容,因此您可以保留现有代码。
- 如需显示许多不同的项类型,请使用
groupBy
函数。
包含本指南的集合
本指南属于以下精选快速入门集合,这些集合涵盖了更广泛的 Android 开发目标:
显示列表或网格
借助列表和网格,您的应用可以以视觉上令人愉悦且易于用户使用的形式显示集合。
Compose 基础知识(视频合集)
本系列视频介绍了各种 Compose API,可让您快速了解可用 API 以及如何使用它们。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Lists in Compose\n\n\u003cbr /\u003e\n\nExplore Compose's lazy components, which make it easy to display lists of items.\nLearn how to show different item types, implement sticky headers, and\nprogrammatically control or react to the scroll-position changes. \n\nKey points\n----------\n\n- The [`LazyColumn`](/reference/kotlin/androidx/compose/foundation/lazy/package-summary#LazyColumn(androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.LazyListState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.Alignment.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,kotlin.Function1)) API is built as a DSL, differing from other layouts in Compose.\n- Use `LazyColumn` to display items visible on screen.\n- Use the [`items()`](/reference/kotlin/androidx/compose/foundation/lazy/LazyListScope#items(kotlin.Int,kotlin.Function1,kotlin.Function1,kotlin.Function2)) function to pass items. The lambda defines the content of each of the items, so you can keep the existing code.\n- To display many different item types, use the `groupBy` function.\n\nCollections that contain this guide\n-----------------------------------\n\nThis guide is part of these curated Quick Guide collections that cover\nbroader Android development goals: \n\n### Display a list or grid\n\nLists and grids allow your app to display collections in a visually pleasing form that's easy for users to consume. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/display-a-list-or-grid) \n\n### Compose basics (video collection)\n\nThis series of videos introduces various Compose APIs, quickly showing you what's available and how to use them. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/compose-basics) \n\nHave questions or feedback\n--------------------------\n\nGo to our frequently asked questions page and learn about quick guides or reach out and let us know your thoughts. \n[Go to FAQ](/quick-guides/faq) [Leave feedback](https://issuetracker.google.com/issues/new?component=1573691&template=1993320)"]]