AutoCompleteTextView не отвечает на изменения своего ArrayAdapter

ArrayList кажется, что заполнение просто отлично, но независимо от того, какой подход я использую, мне не удается заставить адаптер заполняться данными. Я пытался добавить вArrayListтакже кArrayAdapter, В любом случае я не могу получить ответ наAutoCompleteTextView уровень или вArrayAdapter сам (и, конечно,AutoCompleteTextView ничего не делает). Кто-нибудь может увидеть, что не так?

public class MainActivity extends Activity implements TextWatcher {
// private AutoCompleteView autoComplete; 
public String TAG = new String("MAINACTIVITY");
public ArrayAdapter<String> autoCompleteAdapter;
public AutoCompleteTextView autoComplete;
public InputStream inputStream;
public List<String> data;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    data = new ArrayList<String>();
    autoCompleteAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line, data);
    autoCompleteAdapter.setNotifyOnChange(true);
    autoComplete = (AutoCompleteTextView) findViewById(R.id.acsayt);
    autoComplete.setHint(R.string.search_hint);
    autoComplete.setThreshold(2);
    autoComplete.addTextChangedListener(this);
    autoComplete.setAdapter(autoCompleteAdapter);
}

// uphold TextWatcher interface methods
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}

public void onTextChanged(CharSequence s, int start, int before, int count) {
    Log.d(TAG, "I detected a text change " + s.toString());
    data.clear();
    queryWebService();
}

private void queryWebService() {
    new Thread(new Runnable() {
        public void run() {
            Log.d(TAG, "spawned thread");

            //  Code in here to set up http connection, query webservice ...

            // parse the JSON response & add items to adapter
            try {
                JSONArray jArray = new JSONArray(resultString);
                int length = jArray.length();
                int countedValues, capturedValues;
                Log.d(TAG, "response had " + length + " items");
                int i = 0;
                while (i < length) {
                    JSONObject internalObject = jArray.getJSONObject(i);
                    String vehicleName = internalObject.getString("name").toString();
                    Log.d(TAG, "vehicle name is " + vehicleName);
                    try {
                        data.add(vehicleName);  
                        autoCompleteAdapter.add(vehicleName);   // not working
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    countedValues = data.size();    // correctly reports 20 values
                    capturedValues = autoCompleteAdapter.getCount();    //  is zero
                    Log.d(TAG, "array list holds " + countedValues + " values");
                    Log.d(TAG, "array adapter holds " + capturedValues + " values");
                    i++;
                }
            } catch (Exception e) {
                Log.d(TAG, "JSON manipulation err: " + e.toString());
            }
        }
    }).start();
}

}

LogCat показывает ожидаемое количество значений из data.size (), но ноль из autoCompleteAdapter.getCount ().

Ответы на вопрос(1)

Ваш ответ на вопрос