为checkBox添加监听器

在android类中动态创建了checkBox。要添加一个onclick 动作监听器上去。
应该怎么实现。

不是在activity中,是在类中创建的。

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<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;
    }
}

check[i]这就是你的checkbox组件,给他添加监听就可以了