In my app, I have an edittext which will contain a user (brought from db). There is the possibility that more than a user be present inside the edittext in the following manner : UserX, UserY, UserZ
I want to make the backspace of the virtual keyboard function in such a way that upon click, it deletes the whole user, rather than each character.
Any hints how to do this? As I did not find anything upon my searches. (perhaps I was using wrong keywords)
I suggest you use a SpannableString.Here is a complete guide : link. Good luck !
You need to look into the listeners for editing text.
Then, when the user presses backspace, delete till you find a space by maybe using a lastIndexOf()
method.
So, you getText()
from EditText
, you substring()
it till the last space character, take that substring and set it as the new text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With