[英]ANDROID AutoComplete using AsyncTask
I have an AutoCompleteTextView in my layout and I want to do an API call which takes the first character entered as a parameter. 我的布局中有一个AutoCompleteTextView,我想进行一个API调用,它将第一个字符作为参数输入。 I do this API call in an AsyncTask to which I pass the first character as a parameter.
我在AsyncTask中执行此API调用,我将第一个字符作为参数传递给它。
What listener should I use on AutoCompleteTextView so that AsyncTask call happens right after the first character is inputted ? 我应该在AutoCompleteTextView上使用什么监听器,以便在输入第一个字符后立即调用AsyncTask?
Try this link http://makovkastar.github.io/blog/2014/04/12/android-autocompletetextview-with-suggestions-from-a-web-service/ 试试这个链接http://makovkastar.github.io/blog/2014/04/12/android-autocompletetextview-with-suggestions-from-a-web-service/
I achieved the above functionality using shared article. 我使用共享文章实现了上述功能。
Fixed this issue using addTextChangedListener. 使用addTextChangedListener修复了此问题。
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.toString().trim().length() == 1) {
isFileReceived = false;
mAirport = new AsyncTaskAirport(s.toString());
mAirport.execute((Void) null);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.