title: How to ListView opens a new activity using onClick?
body: <p>Hi, Everybody.My goal is when I want to click on a specific item from the ListView, it opens a new activity that I've programmed. For example: when I click on "João", I wish it opens a class called Joao. I've tried using a simple code, but it doesn't work. Nothing happens when I click on João's name from ListView.</p>
  
  <p>This is my code that I'm using:</p>
  
  <pre><code>public class Searchsort extends Activity {
  
      private ListView lv1;
      private EditText ed;
      private String lv_arr[]={"John","Mary","Carl","Rose","Charlie","Allan", "João"};
      private ArrayList&lt;String&gt; arr_sort= new ArrayList&lt;String&gt;();
      int textlength=0;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle icicle) {
          super.onCreate(icicle);
          setContentView(R.layout.main);
          lv1 = (ListView)findViewById(R.id.ListView01);
          ed = (EditText)findViewById(R.id.EditText01);
  
          // By using setAdpater method in listview we an add string array in list.
  
          lv1.setAdapter(new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1 ,   lv_arr));
          ed.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) {
                  textlength=ed.getText().length();
                  arr_sort.clear();
                  for(int i=0;i&lt;lv_arr.length;i++) {
                      if(textlength&lt;=lv_arr[i].length()) {
                          if(ed.getText().toString().equalsIgnoreCase((String) lv_arr[i].subSequence(0,  textlength))) {
                              arr_sort.add(lv_arr[i]);
                          }
                      }
                  }
  
                  lv1.setAdapter(new ArrayAdapter&lt;String&gt;  (Searchsort.this,android.R.layout.simple_list_item_1 , arr_sort));
  
              }
          });
      }
  
      public void onListItemClick(ListView parent, View v, int position, long id) {
          if ("João".equals(lv_arr[position])) { 
              Intent myIntent = new Intent(Searchsort.this, Joao.class);
              startActivity(myIntent);
          }
      }
  
  }
  </code></pre>