void init()
{
intcolumnwidth1 = int_scr_wd*55;
intcolumnwidth1 = intcolumnwidth1/100;
for (int i = 0; i < strarr.length-1; i++)
{
strinarr = fun1.sp
Use this:
new Handler().postDelayed(new Runnable() {
public void run() {
TableRow row = (TableRow)table.getChildAt(i);
table.removeView(row);
}
}, 100);
Where i - is row position, wich you want to delete.
You need to know the textview to be deleted. The TextView can be identified by setting a unique id using setId() or using a unique tag using setTag().
It can then be identified by TextView tv = (TextView) tr1.findViewByTag(unique tag);
Use removeView to delete the View.
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);
}
}
Try removeView
row = (TableRow)findViewById(R.id.row);
table.removeView(row);
The other solutions require your rows to have unique ids.
If they don't have unique ids then how about using:
tl.removeView(rowIndex);
In any case, you should try learning how to use SimpleCursorAdapter or CursorAdapter because they are specifically designed for displaying the content of a database query in a list. See Binding to Data with AdapterView.
I realize this is a old thread but I as shocked when I came across this without a decent answer.
I do it like this:
TableLayout table = (TableLayout) findViewById(R.id.myTable);
table.removeAllViews();
That will remove all of the child views, in this case rows and everything. It doesn't seem by your description that you want to delete just one row, but that you want to remove them and then load the rows again. The above code will do the removing part.