This is my code which generates dynamic buttons on run time! I have tried a lot but couldn't remove the previous created dynamic buttons!
This is the code
TableLayout table = (TableLayout)findViewById(R.id.tableForButtons);
TableRow tableRow = new TableRow (this);
tableRow.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT,1.0f
));
table.setId(123);
table.addView(tableRow);
for(int i=0 ; i<ans_length; i++)
{
ImageView button = new ImageView (this);
button.setLayoutParams(new TableRow.LayoutParams(
TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT,1.0f
));
button.setImageResource(R.drawable.a);
button.setId(i);
tableRow.addView(button);
}
Please help me with this and provide me the code which may remove this table layout with all its views!!!