Tirolel Tirolel - 1 month ago 22
Android Question

Limit tablelayout rows, android

I was wondering if it's possible to add a limit such as maximum of row/s to the tablelayout?

So I can, let's say, insert or show only last 100 instead of entire view. The data is dynamically populated and inserted.

Solution

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

Answer

You can check count of rows by getChildCount() method, and add rows only if count is less than 100.