限制表格布局行,android

Limit tablelayout rows, android

我想知道是否可以在表格布局中添加限制,例如最大值 row/s?

比方说,我可以只插入或显示最后 100 个而不是整个视图。数据是动态填充和插入的。

解决方案

    int _tableCount = _tableLayout.getChildCount();
    if(_tableCount > 100)
    {
        _tableLayout.removeViewAt(100);
    }

您可以通过getChildCount()方法检查行数,只有当行数小于100时才添加行。