title: ListView setOnItemClickListener isn't working
body: <p>Like the title says, my setOnItemClickListener isn't working. I looked through everything I've seen so far on SO and couldn't find my error. </p>
  
  <p>This is the code:</p>
  
  <p>This is the problematic class. It isn't the main class, but is called from an intent:</p>
  
  <pre><code>package...;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.util.Log;
  import android.view.Menu;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  
  public class GroupActivity extends Activity {
  
      String group_id = "";
      Context context;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_group);
          context = this;
  
          Intent intent = getIntent();
          group_id = intent.getStringExtra("group_id");
          Log.i("bla", "Launched GroupActivity for group_id " + group_id);
  
          final SubAdapter adapter = new SubAdapter(this, group_id);
          ListView lv = (ListView) findViewById(R.id.listView1);
          lv.setClickable(true);
          lv.setAdapter(adapter);
  
          lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; av, View v, int idx, long lidx) {
                  Log.i("print here", "blaa " + idx);
  
              }
  
          });
  
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  }
  </code></pre>
  
  <p>This is the SubAdapter class:</p>
  
  <pre><code>package...;
  
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.HashMap;
  import java.util.List;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.drawable.BitmapDrawable;
  import android.graphics.drawable.Drawable;
  import android.text.format.DateUtils;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  public class SubAdapter extends BaseAdapter {
  
      private static final int thumb_width = 128;
      private static final int thumb_hight = 128;
      private static Bitmap default_thumb = null;
      private static LayoutInflater inflater = null;
      private final String group_id_;
      private final Activity activity;
      private final SubAdapter t = this;
  
      // used to keep selected position in ListView
      private int selectedPos = -1;   // init value for not-selected
  
      public SubAdapter(Activity a, final String group_id) {
          Drawable d = a.getResources().getDrawable(R.drawable.ic_contact_picture);
          default_thumb = ((BitmapDrawable) d).getBitmap();
          activity = a;
          group_id_ = group_id;
          inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      }
  
      @Override
      public View getView(int idx, View convertView, ViewGroup parent) {
          Log.i("bla2", "getting view with index " + idx);
          View vi = convertView;
  
          if (convertView == null) {
              vi = inflater.inflate(R.layout.sub_list_item, null);
              vi.setClickable(true);
          }
          TextView tv1 = (TextView)vi.findViewById(R.id.textView1);
          TextView tv2 = (TextView)vi.findViewById(R.id.textView2);
          ImageView img = (ImageView)vi.findViewById(R.id.imageView1);
  
          tv1.setText("first name" + " " + "last name");
          tv2.setText("some date");
  
          // put thumbnail
          Bitmap thumb = default_thumb;
          img.setImageBitmap(thumb);
          Log.i("bla3", "index is " + idx + "selected index is " + selectedPos);
          if(selectedPos == idx){
              Log.i("bla4", "inside if");
           }      
          return vi;
      }
  
  
      public void setSelectedPosition(int pos){
      selectedPos = pos;
           // inform the view of this change
           notifyDataSetChanged();
      }
  
      @Override
      public void notifyDataSetChanged() {
          super.notifyDataSetChanged();
      }
  
  }
  </code></pre>
  
  <p>This is the activity_group xml:</p>
  
  <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".GroupActivity" &gt;
  
      &lt;ListView
          android:id="@+id/listView1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:clickable="true"
          android:focusableInTouchMode="false"
          android:focusable="false" &gt;
  
      &lt;/ListView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>This is the sub_list_item xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:clickable="true"
      android:focusable="false" 
      android:focusableInTouchMode="false"&gt;
  
      &lt;ImageView
          android:id="@+id/imageView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:layout_margin="6dp"
          android:src="@drawable/ic_launcher" /&gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_margin="6dp"
          android:layout_toLeftOf="@+id/toggleButton1"
          android:layout_toRightOf="@+id/imageView1"
          android:text="some text"
          android:textAppearance="?android:attr/textAppearance" /&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/textView1"
          android:layout_below="@+id/textView1"
          android:layout_toLeftOf="@+id/toggleButton1"
          android:text="more text"
          android:textAppearance="?android:attr/textAppearance" /&gt;
  
      &lt;ToggleButton
          android:id="@+id/toggleButton1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_margin="6dp"
          android:text="present" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Apart from the click listener, everything else seems to work. The SubAdapter opens properly and the list is populated. 
  Basically what I'm looking for is to get the message "Log.i("print here", "blaa " + idx);" to print - it is the log from the ListView's setOnItemClickListener (look above)</p>
  
  <p>Please let me know if there is any other relevant code missing
  Thanks!!!</p>