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..
Click somewhere in the table. On the Table Layout (or just Table) tab, select Delete, and then select Delete Table.
TableLayout is a ViewGroup that displays child View elements in rows and columns. Note: For better performance and tooling support, you should instead build your layout with ConstraintLayout. TableLayout positions its children into rows and columns.
Try removeView
row = (TableRow)findViewById(R.id.row);
table.removeView(row);
This method I have written removes all rows except the first one. It is useful if you don't want to remove the header row, for example:
private void cleanTable(TableLayout table) {
int childCount = table.getChildCount();
// Remove all rows except the first one
if (childCount > 1) {
table.removeViews(1, childCount - 1);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With