Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override the default behavior of Backspace in AutoCompleteTextView

I'm using a AutoCompleteTextView, the default behavior of the backspace button goes something like this.

Say i type "Ar", this gives me a suggestion "Argentina", i select "Argentina" from the drop down...The Text now becomes "Argentina ". But say i need to remove the last character, so I hit backspace on the keyboard, the AutcompleteTextView removes all the text till the point i typed (ie. the text now becomes "Ar" again).

How do i eliminate this behavior and let the text in the AutoComplete to behave normally?

At first I thought it was some kind of SpannableString so i called "clearSpans()" but it doesn't seem to work. Any pointers?

Thanks in advance. :)

like image 400
st0le Avatar asked Nov 13 '22 08:11

st0le


1 Answers

I think you use the MultiAutoCompleteTextView which add the setTokenizer(new SpaceTokenizer()). If you use AutoCompleteTextView instead of MultiAutoCompleteTextView and remove the setTokenizer(...) the problem will be gone.

like image 168
Ted Yu Avatar answered Nov 16 '22 04:11

Ted Yu