title: AutoCompleteTextView Via XMLParsing onTextChange
body: <p>I have this problem. I need to send a call to my SAX Parser (every time user tries enter name of the student) to get the names. What  I am doing right now is sending a token-string to my HttpHandler which is returning 10 records every time because total no of students are about 40K so I can't parse them all at once. I am calling my AsyncTask for ParsingXML in onTextChanged event of AutoCompletetextview. but still I am not able to set the adapter to Autocomplete. </p>
  
  <pre><code> public ArrayList&lt;AutoCompleteUserDataGetterSetter&gt; parsexml(String token)
      {
           try {
  
                  SAXParserFactory saxPF = SAXParserFactory.newInstance();
  
  
  
                  SAXParser saxP = saxPF.newSAXParser();
                  XMLReader xmlR = saxP.getXMLReader();
  
  
                  URL url = new URL(xyz.com/xyz.ashx?token=+"token"); // URL of the XML
  
  
                  AutoCompleteUserDataXMLHandler myXMLHandler = new AutoCompleteUserDataXMLHandler();
                  xmlR.setContentHandler(myXMLHandler);
                  xmlR.parse(new InputSource(url.openStream()));
  
              } catch (Exception e) {
                  System.out.println(e);
              }
  
              return data=AutoCompleteUserDataXMLHandler.getArrayData();
  
  
      }
  </code></pre>
  
  <p>Here is my AutoCompleteTextViewAdapter Code</p>
  
  <pre><code>ArrayList&lt;AutoCompleteUserDataGetterSetter&gt; data=new ArrayList&lt;AutoCompleteUserDataGetterSetter&gt;();
  
  public UserNewMessageAutoCompleteAdapater(Context context,
          int textViewResourceId,
          ArrayList&lt;AutoCompleteUserDataGetterSetter&gt;data) {
      super(context, textViewResourceId, data);
      // TODO Auto-generated constructor stub
  
         this.context = context;
          this.data=data;
  
  
          vi = (LayoutInflater) context
                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
  
  
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View v = convertView;
  
      final AutoCompleteUserDataGetterSetter i = this.data.get(position);
      if (i != null) {
          Log.d("adapter", "in here");
          AutoCompleteUserDataGetterSetter si = (AutoCompleteUserDataGetterSetter) i;
          v = vi.inflate(R.layout.autocompletetext_layout, null);
          final TextView title = (TextView) v
                  .findViewById(R.id.autocomplete_name);
          TextView userid = (TextView) v
          .findViewById(R.id.autocompleteuserid);
          if (title != null)
              title.setText(si.GetFullName());
          userid.setText(si.GetUserId());
      }
  
      return v;
  }
  
  @Override
  public int getCount() {
      // TODO Auto-generated method stub
      return data.size();
  }
  
  @Override
  public AutoCompleteUserDataGetterSetter getItem(int arg0) {
      // TODO Auto-generated method stub
      return data.get(arg0);
  }
  
  @Override
  public long getItemId(int arg0) {
      // TODO Auto-generated method stub
      return 0;
  }
  </code></pre>
  
  <p>and here is my AsyncTask Class</p>
  
  <pre><code>class SomeTask extends AsyncTask&lt;Void, Void, Void&gt; {
  
      private final ProgressDialog dialog = new ProgressDialog(UserMessagesComposeNewActivity.this);
  
      @Override
      protected void onPreExecute() {
  
      }
  
      @Override
      protected Void doInBackground(Void... voids) {
  
          UserMessagesComposeNewActivity.this.data=parsexml(users.getText().toString());
  
       for(int i=0;i&lt;data.size();i++)
       {
          nameadapter.add(data.get(i).GetFullName());
       useridadapter.add(data.get(i).GetUserId());
       }
  
  if(data==null)
  {
     AutoCompleteUserDataGetterSetter umsgs=new AutoCompleteUserDataGetterSetter();
     umsgs.SetFullName(" ");
     umsgs.SetUserID("");
    data.add(umsgs);
  
  }
  
  return null;
      }
      @Override
      protected void onPostExecute(Void aVoid) {
           if (this.dialog.isShowing()) {
  
  
  
               this.dialog.dismiss();
  
            }
                  users.setAdapter(nameadapter);
  
  
  
      }
  }
  </code></pre>