title: Button OnClick not firing on Android
body: <p>I am a Android Newbie and am having trouble getting the buttons in this table to fire the OnClick event.  The goal is to have a table full of buttons and when they are clicked, do something.  Right now, I just want to output to the console, but it will not call the OnClick method.</p>
  
  <p>I am sure it is a stupid issue and appreciate the help.</p>
  
  <pre><code>public class HiThereActivity extends Activity  {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);  
  
          ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();
  
          names.add("Michael");
          names.add("John");
          names.add("Mike");
          names.add("Tom");
          names.add("Steve");
  
          ArrayList&lt;String&gt; codes = new ArrayList&lt;String&gt;();
  
          codes.add("abcde");
          codes.add("fghij");
          codes.add("klmno");
          codes.add("pqrst");
          codes.add("uvwxy");
          codes.add("12345");
          codes.add("67890");
  
  
  
          TableLayout table = new TableLayout(this);  
  
          table.setStretchAllColumns(true);  
          table.setShrinkAllColumns(true);  
  
          TableRow rowTitle = new TableRow(this);  
          rowTitle.setGravity(Gravity.CENTER_HORIZONTAL);  
  
          TableRow rowConditions = new TableRow(this);  
          rowConditions.setGravity(Gravity.CENTER);  
  
  
          // title column/row  
          TextView title = new TextView(this);  
          title.setText("IH10 Katy Extension - 11/7/2011");  
  
          title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);  
          title.setGravity(Gravity.CENTER);  
          title.setTypeface(Typeface.SERIF, Typeface.BOLD);  
  
          TableRow.LayoutParams params = new TableRow.LayoutParams();  
          params.span = (codes.size() + 1);  
  
          rowTitle.addView(title, params);  
  
          Iterator&lt;String&gt; nameItr = names.iterator();
          while(nameItr.hasNext()){
              TableRow row = new TableRow(this);
              TextView nameLable = new TextView(this);
              nameLable.setText(nameItr.next());
              nameLable.setTypeface(Typeface.DEFAULT_BOLD);
              row.addView(nameLable);
  
              Iterator&lt;String&gt; codeItr = codes.iterator();
              while(codeItr.hasNext()){
                  /*TextView codeLabel = new TextView(this);  
                  codeLabel.setText(codeItr.next());  
                  codeLabel.setTypeface(Typeface.SERIF, Typeface.BOLD);
  
                  row.addView(codeLabel);
                  */
                  codeItr.next();
                  Button rowButton = new Button(this);
                  rowButton.setText("8");
                  //rowButton.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT));
                  rowButton.setOnClickListener(btnListener);
  
  
                  row.addView(rowButton);
  
  
              }
              table.addView(row);
          }
  
  
          setContentView(table);  
      }
  
      private OnClickListener btnListener = new OnClickListener() {
          public void onClick(View v) {
              System.out.println("TEST");
          }
      };
  
  
  }
  </code></pre>
  
  <p>EDIT #1:
  I did some experimenting and did this very simple example the the onClick is not called.  I know it is something really stupid.  Any ideas?</p>
  
  <pre><code>package com.bordeloniphone.timeentry;
  
  import android.app.Activity;
  import android.os.Bundle;
  
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  
  public class TimeEntryActivity extends Activity implements OnClickListener{
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          //setContentView(R.layout.main);
  
          Button okButton = new Button(this);
          okButton.setText(":)");
          okButton.setOnClickListener(this);
          setContentView(okButton);
  
      }
  
  public void onClick(View v) {
      Log.d("TEST", "TEST");
  
  
  }
  
  }
  </code></pre>