I'm trying to remove a row from a table and have everything below that row move up one row. I am not succeeding at all. I've tried iterating through all the cells (with Table.getCells()
) and updating them that way in various ways, but it just doesn't seem to work the way I intend to. Is there a way to do this?
You can remove Actor
with it cell like this:
public static void removeActor(Table container, Actor actor) {
Cell cell = container.getCell(actor);
actor.remove();
// remove cell from table
container.getCells().removeValue(cell, true);
container.invalidate();
}
It's not very handsome solution but it works
A cleaner solution would be the next:
public void removeTableRow(int row) {
SnapshotArray<Actor> children = table.getChildren();
children.ordered = false;
for (int i = row*COLUMN_NUMBER; i < children.size - COLUMN_NUMBER; i++) {
children.swap(i, i + COLUMN_NUMBER);
}
// Remove last row
for(int i = 0 ; i < COLUMN_NUMBER; i++) {
table.removeActor(children.get(children.size - 1));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With