You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 16:32:38