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. 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.
The crash exception is IndexOutOfBoundException caused by Spannable when accessibility talkback is on.
Thanks in advanced.