如何在表格中使用动态创建的复选框

my code above creates a table with checkboxes and textviews inside. the count and the values comes from a MySQL database over php-json. It works all fine. Problem: In the onClickSenden function, I want to check step by step every created checkbox unchecked or checked and do some code depending on.

Its not possible to setId(i), coz "i" is an Iterator and not int.

can u help me?

public class EinbuchungActivity extends Activity implements OnCheckedChangeListener {
    String data = "";
    TableLayout tl;
    TableRow tr;
    TextView label;
    CheckBox cb; 

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_einbuchen);

        TextView tv = (TextView) findViewById(R.id.tvNutzer);
        tv.setText(MainActivity.username);
        TextView tv2 = (TextView) findViewById(R.id.tvKst);
        tv2.setText(MainActivity.kst);

        tl = (TableLayout) findViewById(R.id.maintable);

        final GetDataFromDB getdb = new GetDataFromDB();
        new Thread(new Runnable() {
            public void run() {
                data = getdb.getDataFromDB();
                System.out.println(data);

                runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        ArrayList<Users> users = parseJSON(data);
                        addData(users);                     
                    }
                });

            }
        }).start();
    }

    public ArrayList<Users> parseJSON(String result) {
        //Array-Liste erstellen mit definierter Arrayliste
        ArrayList<Users> users = new ArrayList<Users>();
        try {
            JSONArray jArray = new JSONArray(result);
            //Array-Liste mit Daten füllen
            for (int i = 0; i < jArray.length(); i++) {
                JSONObject json_data = jArray.getJSONObject(i);
                Users user = new Users();
                user.setEan(json_data.getString("ean"));
                user.setName(json_data.getString("name"));
                user.setBetriebszahl(json_data.getString("betriebsdatenalt"));
                users.add(user);
            }
        } catch (JSONException e) {
            Log.e("log_tag", "Error parsing data " + e.toString());  
        }
        return users;
    }

    void addHeader(){
        /** Create a TableRow dynamically **/
        tr = new TableRow(this);

        /** Creating a TextView to add to the row **/
        label = new TextView(this);
        label.setText("Inventarnummer");
        label.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        label.setPadding(5, 5, 5, 5);
        //label.setBackgroundColor(Color.RED);
        LinearLayout Ll = new LinearLayout(this);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT);
        params.setMargins(5, 5, 5, 5);
        //Ll.setPadding(10, 5, 5, 5);
        Ll.addView(label,params);
        tr.addView((View)Ll); // Adding textView to tablerow.

        /** Creating Qty Button **/
        TextView place = new TextView(this);
        place.setText("Name");
        place.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        place.setPadding(5, 5, 5, 5);
        //place.setBackgroundColor(Color.RED);
        Ll = new LinearLayout(this);
        params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT);
        params.setMargins(0, 5, 5, 5);
        //Ll.setPadding(10, 5, 5, 5);
        Ll.addView(place,params);
        tr.addView((View)Ll); // Adding textview to tablerow.

         // Add the TableRow to the TableLayout
        tl.addView(tr, new TableLayout.LayoutParams(
                LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT));
    }

    @SuppressWarnings({ "rawtypes" })
    public void addData(ArrayList<Users> users) {
        addHeader();    
         for (Iterator i = users.iterator(); i.hasNext();) {
            Users p = (Users) i.next();
            /** Create a TableRow dynamically **/
            tr = new TableRow(this);
            /** Creating a Checkbox to add to the row **/
            CheckBox cb = new CheckBox(this);
            cb.setOnCheckedChangeListener(this);
            cb.setText(p.getEan());
            LinearLayout Ll1 = new LinearLayout(this);
            Ll1.addView(cb);
            tr.addView((View)Ll1); // Adding CheckBox to tablerow.  
            /** Creating a TextView to add to the row **/
            label = new TextView(this);
            label.setText(p.getName());
            label.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            label.setPadding(5, 5, 5, 5);
            label.setBackgroundColor(Color.GRAY);
            LinearLayout Ll = new LinearLayout(this);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT);
            params.setMargins(5, 2, 2, 2);
            Ll.addView(label,params);
            tr.addView((View)Ll); // Adding textView to tablerow.

             // Add the TableRow to the TableLayout
            tl.addView(tr, new TableLayout.LayoutParams(
                    LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT));
        }

    }



    public void onClickSenden (View view) {


    }


}
CheckBox cb = new CheckBox(this);
cb.setOnClickListener(this);

Set checkbox id or a tag while creating it.

cb.setTag(someIdentifier);

then use the method

@Override 
public void onClick(View v) {
                 if (v.getTag.equals(someIdentifier)){
                    //do stuff here
                  }    
                }