title: Android - AutoCompleteTextView only works when backspacing
body: <p>I have an <code>AutoCompleteTextView</code> that dynamically updates the list of suggestions as the user types. My problem is that as I type the list gets updated but the drop-down isn't shown! But when I delete a character (backspace) the drop-down shows up! </p>
  
  <p>I even tried to explicitly call the <code>autoText.showDropDown();</code> after the text change but it doesn't work.</p>
  
  <p>Here is my <code>TextChangedListener</code>:</p>
  
  <pre><code>private TextWatcher textChecker = new TextWatcher() {
      @Override
      public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
  
      }
  
      @Override
      public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
          if(autoText.length()&gt;9){
              new GeoTask().execute();
          }
      }
  
      @Override
      public void afterTextChanged(Editable editable) {
          if(autoText.length()&gt;9){
              autoText.showDropDown();
              Log.i("UPDATE","showDropDown");
          }
      }
  };
  </code></pre>
  
  <p>I even tried resetting the adapter above the <code>autoText.showDropDown();</code> but still nothing:</p>
  
  <pre><code>autoText.setAdapter(null);
  autoText.setAdapter(adapter);
  </code></pre>
  
  <p>Is there a way to get it to work?</p>
  
  <hr>
  
  <p><strong>EDIT</strong>: Here is the complete code of the activity. Perhaps someone can find what i am doing wrong...</p>
  
  <pre><code>public class TestDoctor extends Activity {
  
      TextView latText;
      TextView lngText;
      AutoCompleteTextView autoText;
      ArrayAdapter&lt;String&gt; adapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.test_doctor);
  
          latText = (TextView) findViewById(R.id.latTextView);
          lngText = (TextView) findViewById(R.id.longTextView);
          autoText = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
  
  
          Button button = (Button) findViewById(R.id.buttonDoctor);
          button.setOnClickListener(new Button.OnClickListener() {
              public void onClick(View v) {
                  new GeoTask().execute();
              }
          });
          autoText.setThreshold(10);
          autoText.setHint("Οδός Αριθμός, Περιοχή");
          adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_dropdown_item_1line);
          autoText.setAdapter(adapter);
          adapter.setNotifyOnChange(true);
          autoText.addTextChangedListener(textChecker);
      }
  
      private TextWatcher textChecker = new TextWatcher() {
  
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3){}
  
          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
              if(autoText.length()&gt;9){
                  new GeoTask().execute();
              }
          }
  
          @Override
          public void afterTextChanged(Editable editable) {}
      };
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      private List&lt;SimpleAddress&gt; getAddressesFromText(String address) {
          address = address.replace(' ', '+');
          HttpHelper httpHelper = new HttpHelper();
          InputStream inputStream = httpHelper.makeHttpGetRequest("http://maps.google.com/maps/api/geocode/json?address=" + address + "&amp;sensor=false");
          String response = httpHelper.inputStreamToString(inputStream);
  
          List&lt;SimpleAddress&gt; simpleAddresses = new ArrayList&lt;SimpleAddress&gt;();
          try {
              JSONObject jsonObject = new JSONObject(response);
  
  
              int size = ((JSONArray) jsonObject.get("results")).length();
  
              for (int i = 0; i&lt;size; i++){
                  String formatted_address = ((JSONArray) jsonObject.get("results")).getJSONObject(i)
                          .getString("formatted_address");
  
                  Double lng = ((JSONArray) jsonObject.get("results")).getJSONObject(i)
                          .getJSONObject("geometry").getJSONObject("location")
                          .getDouble("lng");
  
                  Double lat = ((JSONArray) jsonObject.get("results")).getJSONObject(i)
                          .getJSONObject("geometry").getJSONObject("location")
                          .getDouble("lat");
                  simpleAddresses.add(i,new SimpleAddress(formatted_address,lat,lng));
              }
              return simpleAddresses;
          } catch (JSONException e) {
              return null;
          }
      }
  
      public class GeoTask extends AsyncTask&lt;Void, Void, Void&gt; {
          List&lt;SimpleAddress&gt; simpleAddresses = new ArrayList&lt;SimpleAddress&gt;();
  
          @Override
          protected Void doInBackground(Void... voids) {
              Log.i("UPDATE","1");
              try {
                  simpleAddresses = getAddressesFromText(autoText.getText().toString());
              } catch (NullPointerException e) {
              }
              Log.i("UPDATE","2");
              return null;
          }
  
          @Override
          protected void onPostExecute(Void aVoid) {
              Log.i("UPDATE", "3");
  
              int size = simpleAddresses.size();
  
              if(size &gt; 0){
                  adapter.clear();
                  Log.i("ADAPTER_SIZE",""+size);
                  for (int i = 0; i&lt; size; i++){
                      adapter.add(simpleAddresses.get(i).getFormatted_address());
                      Log.i("ADDED",simpleAddresses.get(i).getFormatted_address());
                  }
                  Log.i("UPDATE","4");
                  autoText.setAdapter(null);
                  autoText.setAdapter(adapter);
                  autoText.showDropDown();
                  Log.i("UPDATE","showDropDown");
              }
              super.onPostExecute(aVoid);
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT 2</strong>
  i tried also this but still it doesn't work. The dropdown shows only when i press the backspace...</p>
  
  <pre><code>@Override
  public void afterTextChanged(Editable editable) {
      runOnUiThread(updateAdapter);
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>private Runnable updateAdapter = new Runnable() {
  
      public void run(){
          Log.i("ADAPTER_UPDATE","start");
          adapter.notifyDataSetChanged();
          autoText.showDropDown();
          Log.i("ADAPTER_UPDATE","end");
      }
  };
  </code></pre>
  
  <hr>
  
  <p><strong>NOTE</strong>
  The problem is: I type an address. As i type nothing shows up. But i see in the logcat the the adapter is updated. But the dropdown doesn't show. Then when i delete one character the dropdown shows up??!!</p>