如何在Jetpack Compose的LazyRow中遍历Map集合并展示图片?
问题:将Map集合中CastModel的图片展示到LazyRow中
我尝试把CastModel中的图片展示到LazyRow(原本打算用LazyColumn,实际代码用了LazyRow)里,但由于数据是Map集合,不清楚具体实现方式。相关代码如下:
LazyRow 实现代码
LazyRow( horizontalArrangement = Arrangement.spacedBy(8.dp), contentPadding = PaddingValues(horizontal = 16.dp), modifier = Modifier.fillMaxWidth() ) { items(dish.integrates.entries.toList()) { entry -> AsyncImage( model = entry.value.imageUrl, contentDescription = null, modifier = Modifier.size(50.dp), contentScale = ContentScale.Crop ) } }
DishDetailModel.kt
data class DishDetailModel( var title: String? = null, var description: String? = null, var image: String? = null, var time: String? = null, var category: ArrayList<String> = ArrayList(), var integrates: Map<String, CastModel> ) : Serializable
CastModel.kt
data class CastModel( var castName: String? = null, var imageUrl: String? = null ) : Serializable
内容的提问来源于stack exchange,提问作者Captai-N
相关产品推荐
相关产品推荐

