android how to dynamically bind checkboxes with custom listview
<p>I create checkboxes dynamically &amp; i want to bind that checkboxes to listview.
how can i do that.
plz give me the answer
<a href="http://stackoverflow.com/editing-help">http://stackoverflow.com/editing-help</a>
Here i give my code--
public class HomeActivity extends ListActivity{
    CheckBox[] chk;
    ListView lv1;
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        lv1=(ListView)findViewById(R.id.listTasks);
        tv1=(TextView) findViewById(R.id.tvMsg);</p>

<pre><code>    db = new DBAdapter(HomeActivity.this);
    db.open();//int[] id=new int[]{Integer.parseInt(DBAdapter.ID)};
</code></pre>

<p>Cursor cr=db.getUncompletedTask();//my database funtion to retrive values to create checkboxes
        if (cr.moveToFirst()) {
            do {
                String[] str=new String[2];
                str[0]=cr.getString(0);
                str[1]=cr.getString(1);
                al.add(str);
            } while (cr.moveToNext());
        }
        startManagingCursor(cr);
        String[] tasks = new String[] { DBAdapter.KEY_TODO };</p>

<pre><code>    int[] idchk=new int[al.size()];//here i am creating checkbox dynamicaly
    if (al.size() != 0) {
        chk = new CheckBox[al.size()];
        System.out.println(al.size());
        for (int i = 0; i &lt; al.size(); i++) {
            String[] s = (String[]) al.get(i);
            System.out.println("ID: "+s[0]);
            Task_Id = Integer.parseInt(s[0]);
            Task_Nm = s[1];
            chk[i] = new CheckBox(HomeActivity.this);
            System.out.println(i +"task id"+Task_Id +"parseint"+Integer.parseInt(s[0]+chk[i].getText().toString()));
            chk[i].setId(Task_Id);
            idchk[i]=Task_Id;
            chk[i].setText(Task_Nm);
            //lv1.addView(chk[i]);         
            //setContentView(lv1); 
        }
</code></pre>

<p>Here what can i write here so that this dynamically created checkboxes will be bind to listview
}</p>

<p>}</p>

<p>plz give me the appropriate ans for this.</p>
