title: How to implement autocompletetextview with listview?
body: <p>I am getting response from server and display it using listview and it works fine,now what I am trying is i added autocompletetextview to search items by name,but when i run my app it crashes and showing errors..i already ask this </p>
  
  <p>Tab1Activity.java</p>
  
  <pre><code>   public class Tab1Activity  extends ListActivity{
  
  
  private ProgressDialog pDialog;
  JSONArray Product=null;
  private ListView listview;
  ArrayList&lt;HashMap&lt;String,String&gt;&gt; aList;
  
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; arrayTemplist;
  private static String PRODUCT_URL = "";
  private static final String PRODUCT_DATA="Product";
  private static final String PRODUCT_ID="productid";
  private static final String PRODUCT_NAME="product_name";
  private static final String PRODUCT_CODE="skucode";
  private static final String PRODUCT_IMAGE="product_photo";
  private static final String PRODUCT_WEIGHT="weight";
  private static final String PRODUCT_SALERATE="sale_rate";
  //private static final String PRODUCT_LOCATION="weight";
  private CustomAdapterTabone adapter;
  private TextView noacpt;
  private AutoCompleteTextView inputSearch;
  
  @Override
     protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.list_view_tabone);
      //noacpt=(TextView)findViewById(R.id.no_acceptedlist);
      /*String strtext = getIntent().getStringExtra("id");
  System.out.println("&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; id : " + strtext);*/
  
      final ListView listview = (ListView)findViewById(android.R.id.list);
      //listview.setSelector( R.drawable.list_selector);
  
      //listview.setSelector(R.drawable.listselector);
      new LoadAlbums().execute();
  
      aList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      final ListView lv = getListView();
  
      inputSearch = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
  
      inputSearch.addTextChangedListener(new TextWatcher() {
  
  
          @Override
          public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
  
              arrayTemplist= new ArrayList&lt;HashMap&lt;String,String&gt;&gt;();
              String searchString =inputSearch.getText().toString().toLowerCase();
  
              for (int i = 0; i &lt; aList.size(); i++)
              {
                  String currentString =aList.get(i).get(Tab1Activity.PRODUCT_NAME);
                  if (currentString.toLowerCase().startsWith(searchString ))
                  {
                      arrayTemplist.add(aList.get(i));
                  }
              }
  
              for (int i = 0; i &lt; arrayTemplist.size(); i++)
              {
                  String currentstrin = arrayTemplist.get(i).get(Tab1Activity.PRODUCT_NAME);
                  //Toast.makeText(getApplicationContext(), currentstrin, Toast.LENGTH_LONG).show();
  
              }
  
              adapter=new CustomAdapterTabone(getApplicationContext(), arrayTemplist);
              listview.setAdapter(adapter);
  
      /*  SimpleAdapter adapters = new SimpleAdapter(Tab1Activity.this, arrayTemplist,R.layout.list_item_tabone, new String[] { PRODUCT_NAME
              }, new int[] {
                      R.id.txtpronameacptedlist});
              lv.setAdapter(adapters);
              */
          }
  
          @Override
          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                  int arg3) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void afterTextChanged(Editable arg0) {
              // TODO Auto-generated method stub                         
          }
      });
  
  
    }
  
      @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
  Intent intent = new Intent(getApplicationContext(), AllProductDetails.class);
  intent.putExtra("productid", aList.get(position).get(PRODUCT_ID));
  startActivity(intent);
   }
  
    class LoadAlbums extends AsyncTask&lt;String, String,   ArrayList&lt;HashMap&lt;String,String&gt;&gt;&gt; {
  /**
   * Before starting background thread Show Progress Dialog
   * */
  @Override
  protected void onPreExecute() {
      super.onPreExecute();
      pDialog = new ProgressDialog(Tab1Activity.this);
      pDialog.setMessage("Loading...");
      pDialog.setIndeterminate(true);
     // pDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.custom_progress));
      pDialog.setCancelable(false);
      pDialog.show();
  }
  protected ArrayList&lt;HashMap&lt;String,String&gt;&gt; doInBackground(String... args) {
      ServiceHandler sh = new ServiceHandler();
      // Making a request to url and getting response
      ArrayList&lt;HashMap&lt;String,String&gt;&gt; data = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      String jsonStr = sh.makeServiceCall(PRODUCT_URL, ServiceHandler.GET);
  
      Log.d("Response: ", "&gt; " + jsonStr);
  
      if (jsonStr != null) {
          try {
              JSONObject jsonObj = new JSONObject(jsonStr);
  
              // Getting JSON Array node
              Product = jsonObj.getJSONArray(PRODUCT_DATA);
  
              for (int i = 0; i &lt; Product.length(); i++) {
                  JSONObject c = Product.getJSONObject(i);
                  // creating new HashMap
                  HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                  // adding each child node to HashMap key =&gt; value
                  map.put(PRODUCT_ID, c.getString(PRODUCT_ID));
                  map.put(PRODUCT_NAME,c.getString(PRODUCT_NAME));
                  map.put(PRODUCT_CODE, c.getString(PRODUCT_CODE));
                  map.put(PRODUCT_IMAGE, c.getString(PRODUCT_IMAGE));
                  map.put(PRODUCT_WEIGHT, c.getString(PRODUCT_WEIGHT));
                  map.put(PRODUCT_SALERATE, c.getString(PRODUCT_SALERATE)+getResources().getString(R.string.rupee));
                 // map.put(INTEREST_ACCEPT_LOCATION, c.getString(INTEREST_ACCEPT_LOCATION));
                  // adding HashList to ArrayList
                  data.add(map);
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
      } else {
          Log.e("ServiceHandler", "Couldn't get any data from the url");
      }
      return data;
  }
  protected void onPostExecute(ArrayList&lt;HashMap&lt;String,String&gt;&gt; result) {
      super.onPostExecute(result);
  
      // dismiss the dialog after getting all albums
      if (pDialog.isShowing())
          pDialog.dismiss();
      // updating UI from Background Thread
  
          aList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
          aList.addAll(result);
          adapter = new CustomAdapterTabone(getApplicationContext(),result);
          setListAdapter(adapter);
  
          aList.addAll(result);
          adapter.notifyDataSetChanged();
  
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>CustomAdapter</p>
  
  <pre><code>  public class CustomAdapterTabone extends BaseAdapter{
  
  
  private Context context;
  private ArrayList&lt;HashMap&lt;String,String&gt;&gt; listData;
  private AQuery aQuery;
  
  private static final String TAG_NAME="product_name";
  private static final String TAG_PROFILE="skucode";
  private static final String TAG_IMAGE="product_photo";
  private static final String TAG_CAST="weight";
  private static final String TAG_AGE="sale_rate";
    // private static final String TAG_LOCATION="weight";
  
  public CustomAdapterTabone(Context context,ArrayList&lt;HashMap&lt;String,String&gt;&gt; listData) {
      this.context = context;
      this.listData=listData;
      aQuery = new AQuery(this.context);
  }
  
  @Override
  public int getCount() {
      return listData.size();
  }
  
  @Override
  public Object getItem(int position) {
      return listData.get(position);
  }
  
  @Override
  public long getItemId(int position) {
      return position;
  }
  
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
      ViewHolder holder;
      if (convertView == null) {
          holder = new ViewHolder();
          convertView = LayoutInflater.from(context).inflate(R.layout.list_item_tabone, null);
          holder.propic = (ImageView) convertView.findViewById(R.id.propicaccept);
          holder.txtproname = (TextView) convertView.findViewById(R.id.txtpronameacptedlist);
          holder.txtproid = (TextView) convertView.findViewById(R.id.txtproidacptedlist);
          holder.txtprofilecast = (TextView) convertView.findViewById(R.id.txtprofilecastacptedlist);
          holder.txtprofileage = (TextView) convertView.findViewById(R.id.txtprofileageacptedlist);
         // holder.txtprofileplace = (TextView) convertView.findViewById(R.id.txtprofileplaceacptedlist);
          convertView.setTag(holder);
      }else{
          holder = (ViewHolder) convertView.getTag();
      }
  
      holder.txtproname.setText(listData.get(position).get(TAG_NAME));
      holder.txtproid.setText(listData.get(position).get(TAG_PROFILE));
      holder.txtprofilecast.setText(listData.get(position).get(TAG_CAST));
      holder.txtprofileage.setText(listData.get(position).get(TAG_AGE));
      //holder.txtprofileplace.setText(listData.get(position).get(TAG_LOCATION));
  
      aQuery.id(holder.propic).image(listData.get(position).get(TAG_IMAGE),true,true,0,R.drawable.ic_launcher);
      // image parameter : 1 : memory cache,2:file cache,3:target width,4:fallback image
      return convertView;
  }
  class ViewHolder{
      ImageView propic;
      TextView txtproname;
      TextView txtproid;
      TextView txtprofilecast;
      TextView txtprofileage;
      TextView txtprofileplace;
  }
  }
  </code></pre>