I have created a table layout in xml. At runtime, i am using a condition where in first case i am filling table layout. However in second case i am again adding contents to the same layout. And they get added up at the end of layout. However i need to clear the previous contents of layout.
I can use these removeallview() method,It doesn’t work.. my code as
ll=(LinearLayout)findViewById(R.id.linear1);
for (int i = 0; i <= 1; i++) {
table=new TableLayout(mContext);
TableLayout.LayoutParams tableParams= new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT);
int leftMargin=0;
int topMargin=0;
int rightMargin=0;
int bottomMargin=0;
tableParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
table.setLayoutParams(tableParams);
lf_header = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
header_view = lf_header.inflate(R.layout.header, null);
DBAdapter dbAdapter=DBAdapter.getDBAdapterInstance(this);
try {
dbAdapter.createDataBase();
} catch (IOException e) {
Log.i("*** select ",e.getMessage());
}
dbAdapter.openDataBase();
if(i==0){
((TextView) header_view.findViewById(R.id.header_txt1)).setText("Over Due");
header_view.setBackgroundColor(Color.RED);
table.addView(header_view);
ll.addView(table);
Any suggestions ??
example code is appreciate..
Thanks in advance..
try
table.removeAllViewsInLayout()