Add onClick Action Listener for dynamically created CheckBox
<p>I am creating CheckBoxes Dynamically in an Android Class <strong><em>(Not Activity)</em></strong>. So I need to add <code>onClick</code> Action Listener to my checkboxes, how to implement this.</p>

<p>I am using following code.</p>

<pre><code>public class DataBaseAdapter extends SQLiteOpenHelper
{
    ...//onCreate and onUpdate
    ...
    ...
    public TableLayout getAllAlarmList(Context con)
    {
            TableLayout tb = new TableLayout(con);
            TableRow[] tr = new TableRow[maxCount]; //maxCount is the number of rows 
            CheckBox[] check = new CheckBox[maxCount]; //maxCount is the number of rows in the database.
            for(int i=0;i&lt;maxCount;i++)
            {
                tr[i]=new TableRow(con);
                check[i]= new CheckBox(con); //con is Context class passed as argument.
                check[i].setText(Integer.toString(i));
                check[i].setId(100+i);
                // I have to add onClick Action Listener here.
                tr[i].addView(check[i]);
                tb.addView(tr[i]);
            }
            return tb;
    }

}
</code></pre>

<p>For this I am also keeping a track of the ids of the checkboxes.</p>
