0Pricing
Jetpack Compose Academy · บทเรียน

LazyColumn กับคอลัมน์แบบเลื่อนได้

เข้าใจว่าเหตุใดรายการแบบขี้เกียจจึงรองรับข้อมูลขนาดใหญ่ได้ดี

LazyColumn กับคอลัมน์แบบเลื่อนได้ เป็นบทเรียน Jetpack Compose Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Jetpack Compose Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Jetpack Compose Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

The Long-List Problem

When a list has hundreds of rows, you can't draw them all at once. You need a list that only builds what's actually visible on screen.

A Plain Column Builds Everything

A regular Column composes every single child immediately, even rows far below the screen. With long data, that wastes memory and time.

Column {
    items.forEach { Text(it) }
}

Column Needs verticalScroll

A plain Column doesn't even scroll on its own. You must add a verticalScroll modifier just to move past the screen edge.

Column(Modifier.verticalScroll(rememberScrollState())) {
    items.forEach { Text(it) }
}

Meet LazyColumn

A LazyColumn is the scrollable list built for big data. It composes rows on demand as you scroll, so the cost stays small. 🚀

LazyColumn {
    // items go here
}

Lazy Means On Demand

"Lazy" means a row is only created when it scrolls into view. Off-screen items simply don't exist yet, which keeps things fast and light.

Reuse, Not Rebuild

As rows leave the top, LazyColumn recycles them for new rows entering the bottom. A few dozen rows can serve thousands of items.

The items Block

Inside LazyColumn you describe content with an items block instead of a normal loop. Compose decides which ones to actually build.

LazyColumn {
    items(names) { name ->
        Text(name)
    }
}

Scrolling Is Built In

LazyColumn scrolls by default, so you never wrap it in verticalScroll. Adding one would actually cause a crash.

When a Column Is Fine

For a few fixed rows that all fit on screen, a plain Column is simpler and perfect. Reach for LazyColumn only when the list can grow.

Never Nest the Same Direction

Avoid putting a LazyColumn inside a vertically scrolling Column. The two scroll directions clash, and Compose can't measure the height.

Performance Is the Payoff

The big win is performance: smooth scrolling and steady memory no matter how long the data gets. That's why lazy lists scale.

Quick Check

Time to test which list to reach for.

Recap: Lazy Wins for Big Lists

A Column builds everything up front and needs verticalScroll; a LazyColumn builds rows on demand, recycles them, and scales effortlessly. 🎉

คำถามที่พบบ่อย

บทเรียน “LazyColumn กับคอลัมน์แบบเลื่อนได้” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “LazyColumn กับคอลัมน์แบบเลื่อนได้” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Jetpack Compose Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Jetpack Compose Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “LazyColumn กับคอลัมน์แบบเลื่อนได้”

เข้าใจว่าเหตุใดรายการแบบขี้เกียจจึงรองรับข้อมูลขนาดใหญ่ได้ดี คุณปฏิบัติ Jetpack Compose Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Jetpack Compose Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Jetpack Compose Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “LazyColumn กับคอลัมน์แบบเลื่อนได้” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Jetpack Compose Academy นี้ได้ไหม

ได้ บทเรียน Jetpack Compose Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. LazyColumn กับคอลัมน์แบบเลื่อนได้
  2. items และ itemsIndexed
  3. คีย์สำหรับรายการที่เสถียรและรวดเร็ว
  4. ส่วนหัวติดด้านบนและรายการแบ่งส่วน
← กลับไปที่ Jetpack Compose Academy