글자 TextWathcer를 사용하여 텍스트를 변경할 때마다 autoCompleteTextview ArrayAdapter를 동적으로 업데이트하려고합니다.Android - AutoCompleteTextView 동적 업데이트 문제
텍스트가 변경 될 때마다 새 AsyncTask 및 비동기 작업 (onPostExecute)의 콜백에서 http 요청이 있으며 어댑터에서 clear()를 호출하고 새 항목을 추가 한 다음 notifyDataSetChanged를 호출합니다. 불행히도 자동 완성 드롭 다운이 표시되지 않습니다 ..
제발, 어디로 가야합니까? 여기
코드입니다 :AutoCompleteTextView acCountry = (AutoCompleteTextView)layout.findViewById(R.id.autoComplete);
final ArrayAdapter<RMAutoComplete.ListItem> countriesAdapter = new ArrayAdapter<RMAutoComplete.ListItem>(this.context,android.R.layout.simple_dropdown_item_1line);
acCountry.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > 1)
{
new AsyncTask<String, Void, List<RMAutoComplete.ListItem>>(){
@Override
protected List<ListItem> doInBackground(String... params) {
List<ListItem> l = null;
try {
l = location.getCountryData(params[0]);
} catch (Exception e) {
Log.e(TAG,"error when getCountryData",e);
}
return l;
}
@Override
protected void onPostExecute(List<ListItem> countries) {
countriesAdapter.clear();
if (countries != null)
for (ListItem listItem : countries) {
countriesAdapter.add(listItem);
}
countriesAdapter.notifyDataSetChanged();
}
}.execute(s.toString());
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void afterTextChanged(Editable s) {}
}
);
나는 여기에 비슷한 것을하고있다 !!! http://stackoverflow.com/questions/12854336/autocompletetextview-backed-by-cursorloader – toobsco42