From the course: Android Compose with Kotlin
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Add a LazyGrid to a composable screen - Kotlin Tutorial
From the course: Android Compose with Kotlin
Add a LazyGrid to a composable screen
- [Instructor] For our sample app, we want to dynamically display the list of sessions that we receive from our API. If you take a look at the mock up, it contains two chips up top, which allow users to filter sessions by day. Next, there are cards that contain the information for a given session, laid out in a scrolling list. To accomplish this UI design, we're going to introduce a lazy vertical grid to the session screen. To get started, instead of using a column, we're going to change this to lazy vertical grid. Next, we won't need this additional padding, so I'll simply remove it as well as this reference to the vertical arrangement. Instead, we want to specify the number of columns that we need for our grid. In this case, since we're only going to have one scrolling list, we can use grid sales fixed, and we'll set the count equal to one. The next step is to use the items extension function, which will allow us to iterate over our list of objects. So here on line number 35…
Contents
-
-
-
-
-
-
-
-
(Locked)
Explore lazy layouts in Compose5m 47s
-
(Locked)
Add a LazyGrid to a composable screen6m 24s
-
(Locked)
Handle lazy layout item click events4m 11s
-
(Locked)
Handle loading and empty states7m 53s
-
(Locked)
Display snackbar messages6m 4s
-
(Locked)
Pass data in a ViewModel3m 54s
-
(Locked)
Challenge: Adding some polish1m 36s
-
(Locked)
Solution: Adding some polish2m 9s
-
(Locked)
-
-
-