How to Create Dynamic table which row including two cutom check boxes in Android
i want to crate dynamic table which row contain two check boxes(custom check box) and i want to give to that check box onCheck or onClick event to that particular check box ..how to create such type of dynamic layout in Android?? Pl开发者_Go百科ease help me...
Try out this code:
for(int i=0;i<10;i++)
{
final TableRow table_row = new TableRow(this);
final TextView tv_items = new TextView(this);
tv_items.setText("Textbox"+i);
final CheckBox chk_box_1 = new CheckBox(this);
//final CheckBox chk_box_2 = new CheckBox(this);
table_row.addView(tv_items);
table_row.addView(chk_box_selected_food);
table.addView(table_row, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
chk_box_1.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
// TODO Auto-generated method stub
if(chk_1.isChecked())
{
//your code
}
else
{
//your code
{
}
});
}
The textview is just for demonstration purpose..you can have another checkbox and can handle the same as the first one
精彩评论