I've been looking for hours on how to get all TableRow's in a TableLayout. I already know how to add and delete rows dynamically, but I need to loop over all the rows and selectively delete some of them.
I think I can come up with a work around, but I'm trying to avoid crude hacks in my app.
Have you tried using getChildCount()
and getChildAt(int)
respectively?
Should be fairly easy in a loop:
for(int i = 0, j = table.getChildCount(); i < j; i++) {
View view = table.getChildAt(i);
if (view instanceof TableRow) {
// then, you can remove the the row you want...
// for instance...
TableRow row = (TableRow) view;
if( something you want to check ) {
table.removeViewAt(i);
// or...
table.removeView(row);
}
}
}