filter listView data using SimpleAdapter
<p>i am using simpleAdapter to display names in a listView. i want to add a edittext widget to allow the user to filter for the name they want to find. however, i do not know how to do this. can someone explain how i can do this. here is my code: </p>

<pre><code>   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.jar.Attributes.Name;

   import org.apache.http.NameValuePair;
   import org.json.JSONArray;
   import org.json.JSONException;
   import org.json.JSONObject;

   import android.app.Dialog;
   import android.app.ListActivity;
   import android.app.ProgressDialog;
   import android.os.AsyncTask;
   import android.os.Bundle;
   import android.text.Editable;
   import android.text.TextWatcher;
   import android.util.Log;
   import android.view.View;
   import android.widget.AdapterView;
   import android.widget.AdapterView.OnItemClickListener;
   import android.widget.EditText;
   import android.widget.ListAdapter;
   import android.widget.ListView;
   import android.widget.SimpleAdapter;
   import android.widget.SimpleCursorAdapter;
   import android.widget.TextView;
   import android.widget.Toast;

   public class Patients extends ListActivity{

  private static final String ID = "id";
  private static final String NAME = "name";
  private static final String PATIENTS = "patients";


  private ProgressDialog dialog;

      private EditText search; 

   //URL to get the patient info
   private static final String URL = "http://10.0.2.2:8080/HMS2/patients.php";

   ListAdapter adapter;

    //for getting the parse  data
        JSONParser jParser = new JSONParser();


   // patients JSON ARRAY 
   JSONArray patients = null;

  ArrayList&lt;HashMap&lt;String, String&gt;&gt; patientsList;

 @Override
 protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.all_patients);

    search = (EditText) findViewById(R.id.inputSearch);

    new LoadPatients().execute();

    //selecting single listView
    ListView list = getListView();

    list.isTextFilterEnabled();

    list.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView&lt;?&gt; arg0, View view, int position,
                long id) {

            String name = ((TextView) findViewById(R.id.name)).getText().toString();
        }

    });

} 

 class LoadPatients extends AsyncTask&lt;String, String, String&gt;
  {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();

        dialog = new ProgressDialog(Patients.this);
        dialog.setMessage("Loading patients info...");
        dialog.setIndeterminate(false);
        dialog.setCancelable(false);
        dialog.show();
    }


    @Override
    protected String doInBackground(String... params) {

        //HashMap for ListView
        patientsList = new ArrayList&lt;HashMap&lt;String,String&gt;&gt;();

        HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();


        ArrayList&lt;NameValuePair&gt; query = new ArrayList&lt;NameValuePair&gt;();

        //gets the JSON object 
        JSONObject json = jParser.getJSONFromUrl(URL, query, "POST");

        Log.e("error",json.toString());

        try 
          {
            //gets the JSON array which is patients 
            patients = json.getJSONArray(PATIENTS);

            //loop through the JSON array
            for(int x= 0; x &lt; patients.length(); x++)
             {
                //gets the  key=&gt; value position 
                JSONObject key = patients.getJSONObject(x);

                //gets the id value 
                int value = key.getInt(ID);
                String id = Integer.toString(value);

                //gets the name value
                String name = key.getString(NAME);

                //put the key =&gt; value in a HashMap
                map.put(NAME,  name);
                map.put(ID, id);

                //add the HashMap values to the ArrayList
                patientsList.add(map);

             }
          }
        catch (JSONException e) 
         {  
            Toast.makeText(getApplicationContext(), "Connection problem", Toast.LENGTH_LONG);
         }


        return null;
    }


    @Override
    protected void onPostExecute(String result) 
     {
        super.onPostExecute(result);

          //dismiss the dialog after getting all products
          dialog.dismiss();


          adapter = new SimpleAdapter(getApplicationContext(),patientsList,R.layout.list_item,
                        new String[]{NAME}, new int[]{R.id.name});

          setListAdapter(adapter);              

        }


     }

    }
</code></pre>
