title: How can I filter ListView data when typing on EditText in android
body: <p>I have a ListView and a EditText. How can I filter ListView data when typing on EditText ? </p>
  
  <p>My code is given below: </p>
  
  <pre><code> public class ListContacts extends ListActivity {
  
   ListAdapter lAdapter;
   EditText filterText;
  
   @Override
  public void onCreate(Bundle savedInstanceState) {
  
  super.onCreate(savedInstanceState);
  
  // Associate the xml with the activity
  setContentView(R.layout.activitylist);
  
  
       Cursor cursor = getContentResolver().query(
      ContactsContract.Contacts.CONTENT_URI, null,
      null, null,
       null); 
  
  startManagingCursor(cursor);
  
  // start mappings
  
       String[] columns = new String[] { ContactsContract.Contacts.DISPLAY_NAME };
  int[] names = new int[] { R.id.contact_name };
  
  
       lAdapter = new ImageCursorAdapter(this, R.layout.main, cursor, columns,
      names);
  </code></pre>
  
  <p>/**
       * to filter contacts
       */</p>
  
  <pre><code>filterText = (EditText) findViewById(R.id.EditText01);
  
        filterText.addTextChangedListener(new TextWatcher() {
  
  
  
      public void afterTextChanged(Editable s) {
      }
  
      public void beforeTextChanged(CharSequence s, int start, int count,
          int after) {
      }
  
      public void onTextChanged(CharSequence s, int start, int before,
          int count) {
  
      }
  
  
  
  });
  }
  </code></pre>
  
  <p>}// end of class ListContacts</p>
  
  <pre><code>        public class ImageCursorAdapter extends SimpleCursorAdapter {
  
           private Cursor c;
           private Context context;
  
           public ImageCursorAdapter(Context context, int layout, Cursor c,
      String[] from, int[] to) {
  super(context, layout, c, from, to);
  
  this.c = c;
  this.context = context;
  }
  
  
       public View getView(int pos, View inView, ViewGroup parent) {
  
          }
  </code></pre>
  
  <p>}// end of class ImageCursorAdapter</p>