Jetpack Compose 按钮无法使用文本可组合功能

问题描述 投票:0回答:1

我是 Jetpack Compose 的新手。我遵循文档中的教程。但不幸的是,我无法使用以下代码。

Button(onClick = {

        }) {
            Text(text = "Hello")
        }

错误是

@Composable invocations can only happen from the context of a @Composable function
.

enter image description hereenter image description here

我尝试了一切可能的方法来修复该错误。感谢您的宝贵时间。

我已经尝试了docs中的每个代码片段,但没有任何效果。

android-jetpack-compose android-jetpack-compose-material3
1个回答
0
投票

我找到了解决方案。只需在设置中禁用 K2 Kotlin 模式即可。 img

© www.soinside.com 2019 - 2024. All rights reserved.