Viv*_*odi 2 android kotlin android-jetpack-compose
我想知道我们怎样才能回来Column/Row通过jetpack compose中的lamda函数返回。我尝试了一些东西,但它给了我错误。
配对内容
\n@Composable\nfun PairContent(\n bluetoothEnable: (ColumnScope) -> Unit,\n) {\n AnimatedVisibility(visible = true) {\n Scaffold {\n Column { columnScope ->\n bluetoothEnable(columnScope)\n }\n }\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n错误
\nType mismatch.\nRequired:\nColumnScope.() \xe2\x86\x92 Unit\nFound:\nColumnScope.(Any?) \xe2\x86\x92 Unit\n\nCannot infer a type for this parameter. Please specify it explicitly.\nRun Code Online (Sandbox Code Playgroud)\n图像错误
\n\nColumnScope 应该是您的参数的接收者bluetoothEnable: ColumnScope.() -> Unit
@Composable
fun PairContent(
bluetoothEnable: @Composable ColumnScope.() -> Unit,
) {
AnimatedVisibility(visible = true) {
Scaffold {
Column {
bluetoothEnable()
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1198 次 |
| 最近记录: |