title: Can't set OnCheckedChangeListener to a Checkbox
body: <p>I am trying to set a <code>OnCheckedChangeListener</code> to a <code>CheckBox</code> but my application exits in the run time. I also tried to set listeners for my <code>TextView</code> and I still get the same result. Can anyone help?</p>
  
  <pre><code>import android.app.ListActivity;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.DialogInterface.OnClickListener;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ArrayAdapter;
  import android.widget.CheckBox;
  import android.widget.CompoundButton;
  import android.widget.CompoundButton.OnCheckedChangeListener;
  import android.widget.ImageView;
  import android.widget.ListView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class ListViewActivity extends ListActivity implements OnCheckedChangeListener {
  
  TextView label;
  CheckBox checkBox;
  
  public class MyCustomAdapter extends ArrayAdapter&lt;String&gt; {
  
  
  public MyCustomAdapter(Context context, int textViewResourceId,
  String[] objects) {
  super(context, textViewResourceId, objects);
  
   // TODO Auto-generated constructor stub
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
  // TODO Auto-generated method stub
  //return super.getView(position, convertView, parent);
  
  View row = convertView;
  
  if(row==null){
  LayoutInflater inflater=getLayoutInflater();
  row=inflater.inflate(R.layout.main, parent, false); 
  
  }  
  
  
  label=(TextView)row.findViewById(R.id.weekofday);
  label.setText(month[position]);
  checkBox=(CheckBox)row.findViewById(R.id.checkBox);
  
  
  return row;
  }
  }
  
  String[] month = {
  "January", "February", "March", "April",
  "May", "June", "July", "August",
  "September", "October", "November", "December"
  };
  
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
  // setContentView(R.layout.main);
   /*setListAdapter(new ArrayAdapter&lt;String&gt;(this,
     R.layout.row, R.id.weekofday, DayOfWeek));*/
  
  
     setListAdapter(new MyCustomAdapter(ListViewActivity.this, R.layout.main, month));
  
     checkBox.setOnCheckedChangeListener(this); //my application exits here!!!!
  
   }
  
  
  
  
  
  @Override
  public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
  // TODO Auto-generated method stub
  //Toast.makeText(getApplicationContext(), "box checked", Toast.LENGTH_LONG);
  
  }
  
  
  }
  </code></pre>