title: How to bind AutoCompleteTextView from HashMap
body: <p>I want to create a AutoCompleteTextView in which user can enter <strong>Zip Code</strong> or <strong>City Name</strong> but only <strong>City Name</strong> should be appear on suggestion drop down.</p>
  
  <p>I am using AsyncTask for getting Church List, and I am using HashMap to store City Name and Zip Code.</p>
  
  <p><strong>Async Class:</strong></p>
  
  <pre><code>    // Asynchronous Class for Fetching All Church.
  public class FetchAllChurch extends AsyncTask&lt;String, String, String&gt; {
  
      Boolean isJsonObjectNull = false;
      HashMap&lt;String, String&gt; cityZipHashMap;
  
      @Override
      protected void onPreExecute() {
          // TODO Auto-generated method stub
          super.onPreExecute();
  
          progressDialog = new ProgressDialog(Search.this);
          progressDialog.setMessage("Loading Cities...");
          progressDialog.setCancelable(true);
          progressDialog.show();
      }
  
      @Override
      protected String doInBackground(String... params) {
          // TODO Auto-generated method stub
          jsonParser = new JsonParser();
          JSONObject jsonObject = jsonParser
                  .makeHttpRequest(Utility.GET_ALL_CHURCH_URL);
          if (jsonObject != null) {
              Log.v("All Church: ", jsonObject.toString());
              try {
                  JSONArray jsonArray = jsonObject
                          .getJSONArray(Utility.SEARCH_RESULT);
  
                  for (int i = 0; i &lt; jsonArray.length(); i++) {
                      JSONObject churchJsonObject = jsonArray
                              .getJSONObject(i);
  
  
                      String ePostalString = churchJsonObject
                              .getString(Utility.E_POSTAL);
                      String eZipCodeFullString = churchJsonObject
                              .getString(Utility.E_ZIP_FULL);
                      String eCityString = churchJsonObject
                              .getString(Utility.E_CITY);
  
                      cityZipHashMap = new HashMap&lt;String, String&gt;();
                      cityZipHashMap.put("city", eCityString);
                      cityZipHashMap.put("zip", ePostalString);
                      cityZipArrayList.add(cityZipHashMap);
  
                      }
  
                  // }
              } catch (JSONException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
          return null;
      }
  
      @Override
      protected void onPostExecute(String result) {
          // TODO Auto-generated method stub
          super.onPostExecute(result);
  
          progressDialog.dismiss();
  
              AutoCompleteAdapter adapter = new AutoCompleteAdapter(
                      getApplicationContext(), android.R.layout.simple_list_item_1, cityZipArrayList);
              searchAutoCompleteTextView.setAdapter(adapter);
          }
  </code></pre>
  
  <p><strong>Adapter:</strong></p>
  
  <p>Here is the adapter:</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.HashMap;
  
  import android.content.Context;
  import android.util.Log;
  import android.widget.ArrayAdapter;
  import android.widget.Filterable;
  
  public class AutoCompleteAdapter extends ArrayAdapter&lt;String&gt;
      implements Filterable {
  private ArrayList&lt;HashMap&lt;String, String&gt;&gt; mData;
  
  public AutoCompleteAdapter(Context context, int textViewResourceId,
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; mData) {
      super(context, textViewResourceId);
      this.mData = mData;
  }
  
  @Override
  public int getCount() {
      return mData.size();
  }
  
  @Override
  public String getItem(int index) {
      return mData.get(index).toString();
  }
  
  @Override
  public android.widget.Filter getFilter() {
      // TODO Auto-generated method stub
  
      android.widget.Filter filter = new android.widget.Filter() {
  
          @Override
          protected FilterResults performFiltering(CharSequence constraint) {
              // TODO Auto-generated method stub
  
              FilterResults filterResults = new FilterResults();
              if (constraint != null) {
                  // A class that queries a web API, parses the data and
                  // returns an ArrayList&lt;Style&gt;
                  ArrayList&lt;String&gt; suggestion = new ArrayList&lt;String&gt;();
                  for (int i = 0; i &lt; getCount(); i++) {
                      if (getItem(i).startsWith(
                              constraint.toString())) {
                          suggestion.add(getItem(i));
  
                          Log.v("Adapter: ", getItem(i)
                                  + "const" +constraint.toString());
                      }
                  }
  
                  // Now assign the values and count to the FilterResults
                  // object
                  filterResults.values = suggestion;
  
                  filterResults.count = suggestion.size();
              }
              return filterResults;
          }
  
          @Override
          protected void publishResults(CharSequence constraint,
                  FilterResults results) {
              // TODO Auto-generated method stub
  
              clear();
              @SuppressWarnings("unchecked")
              ArrayList&lt;String&gt; newValues = (ArrayList&lt;String&gt;) results.values;
              for (int i = 0; i &lt; newValues.size(); i++) {
                  add(newValues.get(i));
  
              }
  
              if (results != null &amp;&amp; results.count &gt; 0) {
                  notifyDataSetChanged();
              } else {
                  notifyDataSetInvalidated();
              }
          }
  
      };
      return filter;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I am not getting expected result.<br>
  Thanks in advance.</p>