title: Android perform real time search
body: <p>I should do so that, by having a list of names in a gridview, from a search bar I can: </p>
  
  <ol>
  <li>Make a real-time-search (like google search for instance)</li>
  <li>to remove the names that do not begin with the letters you type (for
  example if you type  'ja' or 'Ja' or 'JA' the app deletes all the
  names in the list except 'Jack)</li>
  </ol>
  
  <p>I don't know where to start..
  Can you help me?</p>
  
  <p>Here's People.java:</p>
  
  <pre><code>package com.ec.people;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.text.Editable;
  import android.text.TextWatcher;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ArrayAdapter;
  import android.widget.EditText;
  import android.widget.GridView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  
  public class people extends Activity {
      GridView peoplelist;
      EditText search;
  
      static final String[] numbers = new String[] { 
          "Rossi", "Loggia", "Boni",
          "Milanesi", "Mancini", "Cremonesi",
          "Dali - Colombo", "Fiorentini",
          "Trevisani", "Monaldo", "Udinesi - Pagnotto",
          "Beneventi", "Zucchi", "Calabri",};
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.fragment_people);               
  
          search = (EditText)findViewById(R.id.editText1);            
          peoplelist = (GridView)findViewById(R.id.gridView1);            
  
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, numbers);
          peoplelist.setAdapter(adapter);
  
          peoplelist.setOnItemClickListener(new OnItemClickListener() {
              public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) {
                  Toast.makeText(getApplicationContext(),
                      ((TextView) v) .getText(), Toast.LENGTH_SHORT) .show();
              }
  
  
          });
  
          // I use this to perform search
  
                      search.addTextChangedListener(new TextWatcher() {
  
                          @Override
                          public void onTextChanged(CharSequence s, int start, int before, int count) {
  
  
  
  
                              for(int i=0; i &lt; numbers.length ; i++)
                              {
                              if(numbers[1].startsWith(s.toString())  )
                              {
  
  
                              }
                              }
  
                              //PerformSearch mysearch  = new PerformSearch();
  
  
  
                          }
  
  
                          @Override
                          public void afterTextChanged(Editable s) { }
  
                          @Override
                          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
                      });
  
      }
  }       
  </code></pre>