Android: How do you set a spinner to change focus to the next EditText box down after a selection has been made?
I am working on an app that has multiple edittext 开发者_开发问答fields and spinners and i want the focus to be switched to the next edittext box down when a selection is made from the spinner above.
Help
You could add an ItemSelectedListener to your spinner, and call requestFocus on the next editBox.
I know its a old question. but it might help someone
spinner.setOnTouchListener { view: View, _ ->
if (context is Activity) {
Util.hideSoftKeyboard(context as Activity)
(context as Activity).currentFocus?.let {
if (it.hasFocus() && it is EditText) {
it.isFocusable = false
it.isFocusableInTouchMode = false
it.clearFocus()
it.isFocusable = true
it.isFocusableInTouchMode = true
}
}
}
spinner.requestFocus()
}
精彩评论