how to delete table row in table layout in android

Sourabh picture Sourabh · Apr 5, 2011 · Viewed 35.7k times · Source
void init()
{
   intcolumnwidth1 = int_scr_wd*55;
   intcolumnwidth1 = intcolumnwidth1/100;
   for (int i = 0; i < strarr.length-1; i++)
   {
      strinarr = fun1.split(strarr[i].trim(),"^");
      tr1 = (TableRow) new TableRow(this);
      txt1=new TextView(this);
      txt1.setWidth(intcolumnwidth1);
      txt1.setText(strinarr[0]);
      tr1.addView(txt1);
      tl.addView(tr1,new TableLayout.LayoutParams(layoutParams));
   }
}

Scenario is this when for the first i open this page it dynamically adds rows in the table layout ... but if after some time data in database changes ... when i click on refresh button it appends the new data after the old data in the table layout... all i need is the solution for how to refresh or delete textview that already exists in the table layout...

thanx..

Answer

SteD picture SteD · Apr 5, 2011

Try removeView

row = (TableRow)findViewById(R.id.row);
table.removeView(row);