Build Layouts with Jetpack Compose

Sep 10 2024 · Kotlin 1.9, Android 14, Android Studio Iguana | 2023.2

Lesson 02: Leverage Lists

Demo

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Open the Starter project in the 02-leverage-lists directory of the m3-ljp-materials repo in Android Studio Hedgehog or later.


@Composable
fun GitHubRepoList() {
  val viewModel: MainViewModel = viewModel()
  val state by viewModel.state.observeAsState()
  LazyColumn(
    modifier = Modifier.fillMaxSize(),
    contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp),
    verticalArrangement = Arrangement.spacedBy(16.dp),
  ) {
      state?.forEach { repo ->
        GitHubRepoCard(repo)
        Spacer(modifier = Modifier.height(16.dp))
      }
  }
}
items(state ?: emptyList()) { repo ->
  GitHubRepoCard(repo)
}
import androidx.compose.foundation.lazy.items
See forum comments
Cinema mode Download course materials from Github
Previous: Instruction Next: Conclusion