title: android change autocompletetextview adapter inside TextWatcher
body: <p>I am using AutoCompleteTextView control
  due to the huge data the AutoCompleteTextView adapter gets filled via web service inside TextWatcher onTextChanged event.</p>
  
  <p>But this solution does not really work fine, as the dropdown sometimes shows and sometimes not, and sometimes crash.
  I tried to change to afterTextChanged event but same results</p>
  
  <p>I have seen some answers but they talk about filling the adapter from within the app or SQLite</p>
  
  <p>any Idea how fix these issues i am having</p>
  
  <p>thanks</p>
  
  <pre><code> actvCentre = (AutoCompleteTextView) findViewById(R.id.actvCentre);
          actvCentre.addTextChangedListener(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) {
                  FillCityAuto(charSequence.toString());
                  actvCentre.showDropDown();
              }
  
              @Override
              public void afterTextChanged(Editable editable) {
  
  
              }
          });
  </code></pre>
  
  <p>//--------------------------------------------------------</p>
  
  <pre><code>private void FillCityAuto(String CityIni)
  {
      String sXML="";
  
      // Get XML from Web Service
      try
      {
          SelectWSTask selectWSTask = new SelectWSTask();
          sXML = selectWSTask.execute(CityIni).get();
  
      } catch (InterruptedException e) {
          e.printStackTrace();
      } catch (ExecutionException e) {
          e.printStackTrace();
      }
  
      /** The parsing of the xml data is done in a non-ui thread */
      CityAutoLoaderTask caLoaderTask = new CityAutoLoaderTask();
  
      caLoaderTask.execute(sXML);
  
  }
  </code></pre>
  
  <p>//-------------------------------------------------------------------------</p>
  
  <pre><code>private class SelectWSTask extends AsyncTask&lt;String, String, String&gt; {
  
      private String resp;
  
      private String CallSelectWS(String CityIni) throws IOException, XmlPullParserException {
  
          WebserviceCall com = new WebserviceCall();
  
          String aResponse = com.CityAutoComplete("CityAutoComplete", CityIni);
  
          return aResponse;
      }
  
      @Override
      protected String doInBackground(String... params) {
          try {
              String CityIni = params[0];
  
              resp = CallSelectWS(CityIni);
          } catch (IOException e) {
              e.printStackTrace();
          } catch (XmlPullParserException e) {
              e.printStackTrace();
          }
          return resp;
      }
  
      @Override
      protected void onPostExecute(String result) {
  
      }
  
      @Override
      protected void onPreExecute() {
  
      }
  
  
      @Override
      protected void onProgressUpdate(String... text) {
  
      }
  }
  </code></pre>
  
  <p>//--------------------------------------------------------</p>
  
  <pre><code>private class CityAutoLoaderTask extends AsyncTask&lt;String, Void, List&lt;HashMap&lt;String, String&gt;&gt;&gt;{
  
      /** Doing the parsing of xml data in a non-ui thread */
      @Override
      protected List&lt;HashMap&lt;String, String&gt;&gt; doInBackground(String... xmlData) {
          StringReader reader = new StringReader(xmlData[0]);
  
  
          MsgsXmlParser msgsXmlParser = new MsgsXmlParser();
  
  
  
              /** Getting the parsed data as a List construct */
          List&lt;HashMap&lt;String, String&gt;&gt; CAuto = null;
          try {
              CAuto = msgsXmlParser.parseCityAuto(reader);
          } catch (XmlPullParserException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
  
          return CAuto;
      }
  
      @Override
      protected void onPostExecute(List&lt;HashMap&lt;String, String&gt;&gt; list) {
  
          ArrayList&lt;String&gt; arrayList = new ArrayList&lt;String&gt;();
          int lsize = ((ArrayList) list).size();
          for (int i=0; i&lt;lsize;i++) {
              HashMap&lt;String, String&gt; firstMap = list.get(i);
              String City = firstMap.get("City");
              arrayList.add(City);
          }
         //String a = "";
          arrayAdapter = null;
          arrayAdapter = new ArrayAdapter&lt;String&gt;(ListFilter.this, android.R.layout.simple_list_item_1, arrayList);
          arrayAdapter.notifyDataSetChanged();
          actvCentre.setAdapter(arrayAdapter);
  
          // save index and top position
  
  
      }
  }
  </code></pre>