Help - read all the relevant threads but my onPostExecute is not being called.
I'm trying to dynamically create the autocomplete list for an AutoCompleteTextView by running the list builder on a separate thread using AsyncTask
Here's the basic code.... any ideas?
_artist = (AutoCompleteTextView)findViewById(R.id.artist);
_artist.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable s)
{
_artist.setAdapter(null);
_fetcher = new AutoCompleteFetcher(_artist);
_fetcher.execute();
}
}
public class AutoCompleteFetcher extends AsyncTask<Void, Void, Void>
{
private AutoCompleteTextView _textView;
private String[] _matches;
public AutoCompleteFetcher(AutoCompleteTextView v)
{
super();
_textView = v;
}
protected Void doInBackground(Void... v)
{
_matches = _getMatches();
return null;
}
private String[] _getMatches()
{
// fill the list....... code removed here
// returns populated String[]
}
@Override
protected void onPostExecute(Void result)
{
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(_textView.getContext(),
android.R.layout.simple_list_item_1,_matches);
_textView.setAdapter(adapter);
}
}