A
Android Central Question
I have an edittext for date and it automatically adds a slash for the date. To do so, I have a text change listener with this code in it.
if (currentTextLength == 2 || currentTextLength == 5) {
editText.setText("$s/")
editText.setSelection(editText.text.length)
}
setSelection places the cursor at the end of the text but it is taking the value as Spannable(if you look at its implementation) which will crash when Accessibility talkback is turned on.
The crash exception is IndexOutOfBoundException caused by Spannable when accessibility talkback is on. Spannable keeps crashing apps as far as I know because it happens too when I use SpannableString.
Is there a way to place the cursor at the end of the edittext without using setSelection? I tried append but it is not placing the cursor at the end.
Thanks in advanced.
if (currentTextLength == 2 || currentTextLength == 5) {
editText.setText("$s/")
editText.setSelection(editText.text.length)
}
setSelection places the cursor at the end of the text but it is taking the value as Spannable(if you look at its implementation) which will crash when Accessibility talkback is turned on.
The crash exception is IndexOutOfBoundException caused by Spannable when accessibility talkback is on. Spannable keeps crashing apps as far as I know because it happens too when I use SpannableString.
Is there a way to place the cursor at the end of the edittext without using setSelection? I tried append but it is not placing the cursor at the end.
Thanks in advanced.