Reputation: 65
I tried some variants, one of them:
tv.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
tv.showDropDown();
}
@Override
public void afterTextChanged(Editable editable) {}
});
But, dropdown suggestions shows and hides at once (looks like blink). Is there any way to show drop down after editing text?
Also I added a button (for the test) and added an onclick listener to it, which calls tv.showDropDown();
method and it works well, how I have expected (it means (IMHO) that there is no problems in BaseAdapter, Filter, etc).
Upvotes: 1
Views: 2524
Reputation: 22556
Look @ my answer.. It's very simple hack by resetting text when you get updated data...
autoRailwayFrom.setText(autoRailwayFrom.getText());
https://stackoverflow.com/a/15044017/1136023
Upvotes: 1
Reputation: 5279
I don't think you must be doing all this.. autocomplete should be like automatic..
as in you must just tell it the data that it has to use for autocomplete and voilla you are done. You need not manually do tv.showDropDown()
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES);
textView.setAdapter(adapter);
where COUNTRIES
is an array of string
look here http://developer.android.com/resources/tutorials/views/hello-autocomplete.html
Upvotes: 1