相关疑难解决方法(0)

Jetpack Compose 记得实际上做了什么,它是如何在引擎盖下工作的?

查看 codelab 的基本教程,有一个片段可以在单击时增加按钮上的计数器

@Composable
fun MyScreenContent(names: List<String> = listOf("Android", "there")) {
    val counterState = remember { mutableStateOf(0) }

    Column(modifier = Modifier.fillMaxHeight()) {
        Column(modifier = Modifier.weight(1f)) {
            for (name in names) {
                Greeting(name = name)
                Divider(color = Color.Black)
            }
        }
        Counter(
            count = counterState.value,
            updateCount = { newCount ->
                counterState.value = newCount
            }
        )
    }
}


@Composable
fun Counter(count: Int, updateCount: (Int) -> Unit) {
    Button(
        onClick = { updateCount(count + 1) },
        colors = ButtonConstants.defaultButtonColors(
            backgroundColor = if (count > …
Run Code Online (Sandbox Code Playgroud)

android android-jetpack-compose

7
推荐指数
3
解决办法
1704
查看次数

标签 统计

android ×1

android-jetpack-compose ×1