Reputation: 6018
I'm using libgdx Table to show some info. This information can change sometimes. I would like to change the cells so that they reflect the updated values. Is this possible or are Tables
designed to be static? To clarify, I would like to do is something like this:
class MyTable extends Table{
Cell<Label> cell;
public MyTable(){
super();
cell = add("some value");
// Add many more cells and rows here
}
public void updateCell(String val){
cell.update(val); // How to do this??
}
}
Ideally, I would like to do this without knowing the position of the changed cell, but any solution that requires that info is OK too.
Upvotes: 0
Views: 570
Reputation: 19776
add("some value")
is a convenience method, which actually adds a Label
with the given text.
You can achieve the same by doing this:
Label myLabel = new Label("some value", skin);
add(myLabel);
After that you can change the text by changing the label itself.
public void updateCell(String val){
Label myLabel = (Label) cell.getActor();
myLabel.setText(val);
}
Upvotes: 4