I'm having a weird issue with AutoCompleteTextView
.
I have a AutoCompleteTextView
that shows suggestions of cities when typing in it.
The list of cities is retrieved from a remote server via JSON
. When I use the soft keyboard or the Mic
Button on the soft keyboard, the suggestions work fine. AutoCompleteTextView
does show the suggested cities.
But, I have a problem when I try to set the text using myAutoCompleteTextView.setText("Chi")
, the auto complete does not show..
I have also tried myAutoCompleteTextView.append("Chi")
but still no luck..
The adapter is there, its just that the suggestions don't show.
Any tips?
Thanks.
Yes you are right there is a bug in AutocompleteTextview
to show default suggestion using setText("");
method.
But you can achieve this by adding some more lines of code as below.
autoText.postDelayed(new Runnable() {
@Override
public void run() {
autoText.showDropDown();
}
},500);
autoText.setText("chi");
autoText.setSelection(autoText.getText().length());
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