我正在使用 Jetpack compose 1.0.0-alpha07
。我制作了一个登录屏幕,其中包含TextField
使用其他可组合项自定义的两个 s。
但是,设置ImeAction
似乎keyboardOptions
不起作用。例如ImeAction.Next
不将焦点移动到下一个 TextField。我认为我应该做一些事情来使它成为可能,但没有任何文件或文章曾简单地谈论过ImeOptions
. 这是我的屏幕代码:
登录可组合:
EmailEdit(onChange = { email.value = it })
PasswordEdit(onChange = { password.value = it })
电子邮件编辑:
@Composable
fun EmailEdit(onChange: (String) -> Unit) {
val t = remember { mutableStateOf("") }
TextField(
value = t.value,
onValueChange = { value ->
t.value = value
onChange(value)
},
leadingIcon = { Icon(asset = Icons.Default.Email) },
label = { Text(text = "Email") },
maxLines = 1,
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Next, // ** Go to next **
keyboardType = KeyboardType.Email
),
visualTransformation = VisualTransformation.None
)
} errorHint = "Not a valid email"
)
}
通行证编辑:
@Composable
fun PasswordEdit(onChange: (String) -> Unit) {
val t = remember { mutableStateOf("") }
TextField(
value = t.value,
onValueChange = { value ->
t.value = value
onChange(value)
},
leadingIcon = { Icon(asset = Icons.Default.Security) },
label = { Text(text = "Password") },
maxLines = 1,
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Done, // ** Done. Close the keyboard **
keyboardType = KeyboardType.Text
),
visualTransformation = PasswordVisualTransformation()
)
}
要执行Done
,Next
我应该添加什么代码?