I want to set focus on the next EditText
after the max character length is reached for each EditText
.
I have three EditText
s and a button. The input will be a date as numbers (DD MM YYYY). When two characters are input in EditText1
, I want the focus to automatically move to EditText2
. When two characters are input in EditText2
, I want the focus to move to EditText3
, which should have a max character length of four. After the user has input four characters, the focus should be set on the button.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(layout.activity_main)
EditText1.doOnTextChanged { text, start, count, after ->
if(count == 2) {
month.requestFocus()
}
}
EditText2.doOnTextChanged { text, start, count, after ->
if(count == 2) {
year.requestFocus()
}
}