title: Using setOnItemClickListener for items in listview
body: <p>I have got an app that saves audio on sd card. I've created a listview which retrieves the filesnames from the sdcard. I'm trying to set a listener so when the file name is clicked I can launch another intent that plays that file. when I try to set the listener and pass in a new <code>OnItemClickListener()</code> eclipse is red underlining it. I understand that I have to implement the <code>onItemclick()</code>, this is where I think the intent ought to go.</p>
  <p>Code:</p>
  <pre><code>package com.tecmark;
  
  import java.io.File;
  import java.util.ArrayList;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.os.Environment;
  import android.util.Log;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.AdapterView.OnItemSelectedListener;
  
  public class SdGetList extends Activity {
      private ListView lv1;
      private String[] lv_arr;
      private ArrayList&lt;String&gt; arr;
          
      @Override
      public void onCreate(Bundle icicle) {
          super.onCreate(icicle);
          setContentView(R.layout.listlayout);
          arr = new ArrayList&lt;String&gt;();
  
          File sdCardRoot = Environment.getExternalStorageDirectory();
          Log.i(&quot;root on sd =&quot;, &quot;&quot;+ sdCardRoot.getPath());
  
          for (File f : sdCardRoot.listFiles()) {
              if (f.isFile()){
                  String name = f.getName();
                  arr.add(name);
                  Log.i(&quot;arr is empty?******&quot;, &quot;&quot;+arr.isEmpty());
              }
              else {
                  Log.i(&quot;file&quot;, &quot; no file&quot;);
              }
              Log.i(&quot;arr******&quot;, &quot;&quot;+arr.size());
          }
          lv_arr = new String[arr.size()];
  
          for(int i=0 ; i&lt;arr.size();i++) {
              lv_arr[i] = arr.get(i);
          }
  
          lv1=(ListView)findViewById(R.id.ListView01);
          // 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));
          lv1.setOnItemClickListener(new OnItemClickListener() {
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              }
          } );
      }
  }
  </code></pre>