【发布时间】:2016-07-28 05:24:51
【问题描述】:
我的布局中有一个 AutoCompleteTextView,我想做一个 API 调用,它将输入的第一个字符作为参数。我在 AsyncTask 中执行此 API 调用,我将第一个字符作为参数传递给它。
我应该在 AutoCompleteTextView 上使用什么侦听器,以便在输入第一个字符后立即调用 AsyncTask?
【问题讨论】:
-
见this
-
使用 addTextChangedListener 修复了这个问题。
-
@Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.toString().trim().length() == 1) { mAirport = new AsyncTaskAirport(s.toString()); mAirport.execute((Void) null); }
-
您不需要任何
TextWatcher或AsyncTask,请参阅我在上面发布的链接
标签: android android-asynctask autocomplete