简体   繁体   English

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

[英]How to manually import extension functions when using Jetpack Compose 1.0.0-alpha11?

I have a List<Item> that I want to be displayed using Jetpack Compose.我有一个想要使用 Jetpack Compose 显示的List<Item> In version "1.0.0-alpha10", this code:在版本“1.0.0-alpha10”中,此代码:

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

Works fine, but, starting with "1.0.0-alpha11", according to the new updates :工作正常,但是,根据新的更新,从“1.0.0-alpha11”开始:

New items(count: Int) factory method for scope of LazyColumn/LazyRow/LazyVerticalGrid. LazyColumn/LazyRow/LazyVerticalGrid 的 scope 的新项目(计数:Int)工厂方法。 items(items: List) and itemsIndexed(items: List) are now extension functions so you have to manually import them when used. items(items: List) 和 itemsIndexed(items: List) 现在是扩展函数,因此您必须在使用时手动导入它们。

My app doesn't work any more.我的应用程序不再工作了。 I'm not sure I understand:我不确定我是否理解:

items(items: List) are now extension functions so you have to manually import. items(items: List) 现在是扩展功能,因此您必须手动导入。

What does it mean?这是什么意思? How to solve this issue?如何解决这个问题?

Thanks in advance.提前致谢。

You need to add this import for the extension function LazyListScope.items() :您需要为扩展 function LazyListScope.items()添加此导入:

import androidx.compose.foundation.lazy.items

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当应用程序从应用程序列表中关闭时,WorkManager 1.0.0-alpha11在API &lt;= 22上不起作用 - WorkManager 1.0.0-alpha11 not working on API <= 22 when app closes from app list Jetpack 撰写“文本”function 已弃用 (1.0.0-alpha09) - Jetpack compose “Text” function deprecated (1.0.0-alpha09) Jetpack compose - 使用 1.0.0-alpha02 嵌套导航 - Jetpack compose - nested navigation with 1.0.0-alpha02 OutlineTextField 、TextField 在 Jetpack Compose 1.0.0-alpha02 中不起作用 - OutlineTextField , TextField not working in Jetpack Compose 1.0.0-alpha02 升级到带有 Kotlin 1.4.30 错误的 Jetpack Compose 1.0.0-alpha12 - Upgrading to Jetpack Compose 1.0.0-alpha12 with Kotlin 1.4.30 error 如何使用新的 compose 1.0.0-alpha09 - how can I use the new compose 1.0.0-alpha09 您正在使用的 compose 编译器插件(版本 1.0.0-alpha13)需要最低运行时版本 1.0.0-alpha13 - The compose compiler plugin you are using (version 1.0.0-alpha13) expects a minimum runtime version of 1.0.0-alpha13 Jetpack Compose Crossfade 在 Alpha 中损坏 - Jetpack Compose Crossfade broken in Alpha 在 Jetpack @Compose 函数中使用 LiveData 作为状态 - Using LiveData as state inside Jetpack @Compose functions 使用 Material Design 3 时如何在 Jetpack Compose 中定义按钮的形状 - How to define shape for Button in Jetpack compose when using Material design 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM