删除tablelayout中的tableRows

时间:2018-03-20 15:30:26

标签: android xamarin rows tablelayout dynamically-generated

我尝试使用以下方法删除tableLayout中的行:

  • table.RemoveAllViews()
  • table.RemoveAllViewInLayout()
  • table.RemoveViewAt()

但它没有用。

我的所有行都是动态添加的。

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

如果要清除所有表格,可以使用以下方法在 循环中逐个删除表格子项:

int count = table.getChildCount();
for (int i = 0; i < count; i++) {
    View child = table.getChildAt(i);
    table.removeView(child);
}