Jetpack compose,添加到组合后自动聚焦于TextField

时间:2021-05-13 10:58:29

标签: android uitextfield focus android-jetpack-compose setfocus

在我的代码中,编辑输入正在动态添加到 ui:

    val content: Content by model.content.observeAsState(NoContent)
    val editContent: EditContent? = content as? EditContent
    if (editContent != null) {
        var text by rememberSaveable{ mutableStateOf( editContent.currentValue?.toString() ?: "") }
        TextField(value = text, onValueChange = {text = it})
    }

如何使TextField在添加后立即聚焦并出现软件键盘?

0 个答案:

没有答案