รายการใน "เขียน"
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สำรวจคอมโพเนนต์แบบ Lazy ของ Compose ซึ่งช่วยให้แสดงรายการรายการต่างๆ ได้ง่าย
ดูวิธีแสดงรายการประเภทต่างๆ ใช้ส่วนหัวแบบติดแน่น และควบคุมหรือตอบสนองต่อการเปลี่ยนแปลงตำแหน่งการเลื่อนแบบเป็นโปรแกรม
ข้อมูลสำคัญ
- API ของ
LazyColumn
สร้างขึ้นเป็น DSL ซึ่งแตกต่างจากเลย์เอาต์อื่นๆ ใน Compose
- ใช้
LazyColumn
เพื่อแสดงรายการที่มองเห็นบนหน้าจอ
- ใช้ฟังก์ชัน
items()
เพื่อส่งรายการ Lambda จะกําหนดเนื้อหาของรายการแต่ละรายการ คุณจึงเก็บโค้ดที่มีอยู่ได้
- หากต้องการแสดงรายการประเภทต่างๆ หลายรายการ ให้ใช้ฟังก์ชัน
groupBy
คอลเล็กชันที่มีคู่มือนี้
คู่มือนี้เป็นส่วนหนึ่งของคอลเล็กชันคู่มือฉบับย่อที่มีการดูแลจัดการ ซึ่งครอบคลุมเป้าหมายการพัฒนา Android ที่กว้างขึ้น ดังนี้
แสดงรายการหรือตารางกริด
รายการและตารางกริดช่วยให้แอปแสดงคอลเล็กชันในรูปแบบที่ดึงดูดสายตาและใช้งานง่ายสำหรับผู้ใช้
องค์ประกอบพื้นฐาน (คอลเล็กชันวิดีโอ)
ชุดวิดีโอนี้จะแนะนำ Compose API ต่างๆ โดยแสดงสิ่งที่มีให้ใช้งานและวิธีใช้อย่างรวดเร็ว
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],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)"]]