[英]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.