Skip to content

Load and Display Images from the Internet, LazyVerticalGrid items() usage #233

@ReggThims

Description

@ReggThims

URL of codelab:

Specify the language of the codelab if it is not English:

In which task and step of the codelab can this issue be found?
4. Load and display Images from the Internet

Describe the problem
In the LazyVerticalGrid code, the use of items(...) does not match the item() code that the IDE can see. I changed it to:

@composable
fun PhotosGridScreen(
photos: List,
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(0.dp)
) {
LazyVerticalGrid(
columns = GridCells.Adaptive(150.dp),
modifier = modifier.padding(horizontal = 4.dp),
contentPadding = contentPadding,
) {
items(count = photos.size, key = {index -> photos[index].id}) { index ->
MarsPhotoCard(
photos[index],
modifier = modifier
.padding(4.dp)
.fillMaxWidth()
.aspectRatio(1.5f)
)
}
}
}

In general, working through the tutorials with up to date Android Studio is punctuated by IDE advice to update components and tools, but if you do, you get lots of problems due to changes in system components and libraries. The items() issue also affects the first tutorial that uses LazyVerticalGrid()..

Steps to reproduce?
work through the tutorial...

Versions
_Android Studio version:_Android Studio Narwhal 4 Feature Drop | 2025.1.4
Build #AI-251.27812.49.2514.14217341, built on October 6, 2025
Runtime version: 21.0.8+-14018985-b1038.68 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.windows.WToolkit
Windows 11.0
Kotlin plugin: K2 mode
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 2048M
Cores: 12
Registry:
ide.experimental.ui=true

API version of the emulator: irrelevant (36.1)

Additional information
Include screenshots if they would be useful in clarifying the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions