Libgdx 通过GestureListener中的角色/单元格更新表中的标签文本

Libgdx 通过GestureListener中的角色/单元格更新表中的标签文本,libgdx,Libgdx,也许我只是走错了路 但是,我只想根据标签的方向更改特定标签中的文本。我将Screen和GestureListener实现保持在同一个类中,以减少这个问题可能出现的琐碎废话: public class TestScreen implements Screen, InputProcessor, GestureDetector.GestureListener { 在show()方法中,我有以下内容: Label heading = new Label("1ST", skin); heading.se

也许我只是走错了路

但是,我只想根据标签的方向更改特定标签中的文本。我将Screen和GestureListener实现保持在同一个类中,以减少这个问题可能出现的琐碎废话:

public class TestScreen implements Screen, InputProcessor, GestureDetector.GestureListener {
在show()方法中,我有以下内容:

Label heading = new Label("1ST", skin);
heading.setName("heading");
table.addActor(heading);
Label l = table.findActor("heading");
l.setText("2ND");
在fling()方法中,我有以下内容:

Label heading = new Label("1ST", skin);
heading.setName("heading");
table.addActor(heading);
Label l = table.findActor("heading");
l.setText("2ND");
但是,该标签中的文本不会更改。我尝试将以下行添加到fling()方法中,它返回successful,但文本仍然没有更新

table.swapActors(table.getActor("heading"), l);
为了彻底起见,我尝试了以下几点,但都无济于事:

SnapshotArray<Actor> children = table.getChildren();
int i = children.indexOf(l, false);
children.set(i, l);
我甚至将初始的.addActor()更改为.add(),以便创建/填充表格的单元格,然后尝试在fling()方法中修改表格单元格的值

Cell c = table.getCell(l);
c.setActor(l);
还有这个

Array<Cell> cells = table.getCells();
int i = cells.indexOf(c, true);
cells.get(i).setActor(l);
Array cells=table.getCells();
int i=cells.indexOf(c,true);
细胞。get(i)。setActor(l);
屏幕上似乎没有任何内容可以直观地更新文本-但是,如果我单步执行调试器,则表的actor/cell文本似乎会更新。。。但屏幕上显示的文本始终保持不变。。。这里肯定有我遗漏的东西…

尝试调用标签-这将迫使它更新为更改后的文本

invalidate方法使此参与者的布局无效,导致在下次调用validate()时发生布局()。当需要布局的参与者的状态发生更改,但没有更改参与者的最小、首选、最大或实际大小(这意味着它不会影响父参与者的布局)时,应调用此方法。

我在表上尝试了.invalidate()。。。但不是个别项目。谢谢,这正是我们需要的。