我将 jetpack compose 版本升级到 beta08。我的项目中有一个 LazyColumn,升级后,我无法检测到对项目的点击。单击在 LazyColumn 之外照常工作。代码如下:
LazyColumn(state = listState, modifier = modifier) {
itemsIndexed(userAndImages){ index, userAndImage ->
val paddingHorizontal = 16.dp
val paddingTop = if(index == 0) 16.dp else 8.dp
val paddingBottom = if(index == size -1) 16.dp else 8.dp
ListItem(
modifier = Modifier
.padding(
start = paddingHorizontal,
end = paddingHorizontal,
top = paddingTop,
bottom = paddingBottom
)
.fillMaxWidth()
.clickable {
onImageClicked(userAndImage.image.id)
},
userAndImage = userAndImage
)
}
}
如您所见,我在 listItem 上使用了修饰符,使其可点击。 列表项是:
@Composable
private fun ListItem(modifier: Modifier = Modifier, userAndImage: UserAndImageUI){
Card(modifier = modifier) {
Column {
WebImage(modifier = Modifier
.height(150.dp)
.fillMaxWidth(),
url = userAndImage.image.urlRegular)
UserInfo(
modifier = Modifier.padding(16.dp),
user = userAndImage.user)
val text = userAndImage.image.description ?: userAndImage.image.altDescription
if(text != null){
Divider(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
color = MaterialTheme.colors.onSurface,
)
Text(
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
text = text)
}
}
}
}
如果我降级到 beta07 就可以了,
您是否遇到同样的问题?