title: Set individual onClick events in custom ViewGroup
body: <p>I have created a custom ViewGroup in which I create a couple of custom child Views (in the java code, not xml).
  Each of these childs needs to have the same onClick event.</p>
  
  <p>The method to handle these click events resides in the activity class that uses the layout. How do I set this method as the onClick handler for all child views?</p>
  
  <p>Here is my code simplified.</p>
  
  <p>The custom ViewGroup:</p>
  
  <pre><code>public class CellContainerGroup extends ViewGroup
  {
      CellView[][] CellGrid = new CellView[9][9];
  
      public CellContainerGroup(Context context, AttributeSet attrs) {
          super(context, attrs);
  
          TypedArray a = context.obtainStyledAttributes(R.styleable.CellContainerGroup);
  
          try {
                  //initialize attributes here.       
              } finally {
                 a.recycle();
              }
  
          for(int i = 0; i &lt; 9 ; i++)
              for(int j = 0 ; j &lt; 9 ; j++)
              {
                  //Add CellViews to CellGrid.
                  CellGrid[i][j] = new CellView(context, null); //Attributeset passed as null
                  //Manually set attributes, height, width etc.               
                  //...
  
                  //Add view to group
                  this.addView(CellGrid[i][j], i*9 + j);
              }
      }
  }
  </code></pre>
  
  <p>The activity that contains the method I want to use as the click handler:</p>
  
  <pre><code>public class SudokuGameActivity extends Activity {
  
      //Left out everything else from the activity.
  
      public void cellViewClicked(View view) {
      {
          //stuff to do here...
      }
  }
  </code></pre>