title: ListView in Android, handler for clicking item
body: <p>I have an activity in Android which uses a ListView. When I click on an item in the ListView, I would like to be able to determine which item was clicked. I have the following code:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  
      setContentView(R.layout.listr);
  
     //setupDB();  
     //populateList3();
     ListView lv = (ListView) findViewById(R.id.ListView01);
     lv.setClickable(true);
  
     lv.setOnItemClickListener(new OnItemClickListener() {
  
     public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {      
          Toast.makeText(ListRecords.this,"Clicked!", Toast.LENGTH_LONG).show();
         }
     });
  </code></pre>
  
  <p>}</p>
  
  <p>My layout.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;  
  &lt;LinearLayout  
      xmlns:android="http://schemas.android.com/apk/res/android"  
  
       android:id="@+id/Linear03lr"
       android:layout_width="fill_parent"  
       android:orientation="vertical"  
       android:gravity="center"
       android:layout_height="fill_parent"&gt;  
  
  
   &lt;!--Put form controls here--&gt;  
      &lt;ListView android:id="@+id/ListView01"
  
   android:layout_width="wrap_content"
   android:layout_height="400dp" /&gt;
  
       &lt;Button
          android:id="@+id/previousbutton"
          android:gravity="center_horizontal"
          android:layout_width = "fill_parent"
          android:layout_height = "fill_parent"
  
          android:text="Previous Menu"/&gt;
  &lt;/LinearLayout&gt;  
  </code></pre>
  
  <p>What am I missing here to be able to intercept clicks on the Listview?</p>