为什么 focusManager 在 Jetpack Compose 中不起作用?
我正在尝试使用 imeAction onNext 和 focusDirection.down 将焦点从用户文本字段移动到密码文本字段,但是当我按下键盘的下一个按钮时,焦点被清除。 UI 图像
我在此处显示代码:
val focusManager = LocalFocusManager.current
//we start to implement login screen UI-->
LazyColumn(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
item {
item {
OutlinedTextField(
value = emailValue.value,
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Next,
keyboardType = KeyboardType.Password
),
keyboardActions = KeyboardActions(
onNext ={
focusManager.moveFocus(FocusDirection.Down)
}
),
I am trying move focus from user textfield to password textfield with imeAction onNext and focusDirection.down, but the focus is cleared when I press the next button of the keyboard.
UI image
I show the code here:
val focusManager = LocalFocusManager.current
//we start to implement login screen UI-->
LazyColumn(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
item {
item {
OutlinedTextField(
value = emailValue.value,
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Next,
keyboardType = KeyboardType.Password
),
keyboardActions = KeyboardActions(
onNext ={
focusManager.moveFocus(FocusDirection.Down)
}
),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置 singleLine ,请尝试
简单的示例
Set singleLine , please try
simple example