Hi! I'm having troubles with displaying photos in ...
# compose
i
Hi! I'm having troubles with displaying photos in
HirozontalPager()
It always displays the same photo.
product.photos
is a List<String> with different links to photos.
Copy code
HorizontalPager(
    count = product.photos.size,
    state = pagerState,
) {
    product.photos.forEach { photoUrl ->
        Image(
            painter = rememberAsyncImagePainter(photoUrl),
            modifier = Modifier
                .height(150.dp)
                .fillMaxWidth(),
            contentScale = ContentScale.Fit,
            contentDescription = ""
        )
    }
}
m
I think horizontalPager lambda has an index that you must use to get the list item. Drop the forEach
👍 2
i
Yeah, you're right. Thanks!