android - Jetpack Compose 1.0.0-alpha11如何手动导入扩展函数?

标签 android kotlin android-jetpack-compose composable

我有一个 List<Item>我想使用 Jetpack Compose 显示。在“1.0.0-alpha10”版本中,这段代码:

@Composable
fun ItemsScreen(items: List<Item>) {
    item?.let {
        LazyColumn {
            items(
                    items = items
            ) { item ->
                ItemCard(item = item)
            }
        }
    }
}

工作正常,但是,根据新的 updates,从“1.0.0-alpha11”开始:

New items(count: Int) factory method for scope of LazyColumn/LazyRow/LazyVerticalGrid. items(items: List) and itemsIndexed(items: List) are now extension functions so you have to manually import them when used.

我的应用程序不再工作了。我不确定我是否理解:

items(items: List) are now extension functions so you have to manually import.

这是什么意思?如何解决这个问题?

提前致谢。

最佳答案

您需要为扩展函数添加此导入 LazyListScope.items() :

import androidx.compose.foundation.lazy.items

关于android - Jetpack Compose 1.0.0-alpha11如何手动导入扩展函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66043401/

相关文章:

asp.net - 在 Android 上下载时播放视频

android - android.support.v7 中的 DialogPreference 导致 override nothing 错误

android - 应用插件请求时发生异常 [id : 'com.android.application' ] while integration Jetpack Compose

android - 撰写中的条件导航,无需单击

android - 在 Jetpack Compose 中将高度设置为 Row 相当于 xml 中的wrap_content

android - 如何使用phonegap在状态栏中显示android的推送通知?

android - 需要 personFields 掩码。请指定一个或多个有效路径

android - 如何将抽屉导航放在工具栏下方?

java - 在 Dagger 2 中提供方法

android - 将源附加到 kotlin 库项目不显示在 AS