我正在尝试禁用一个文本按钮,我的代码如下:
// Setup new game button
final TextButton newGameButton = new TextButton("New Game", style);
newGameButton.addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y,
int pointer, int button) {
Tyr.getInstance().setScreen(new GameScreen());
AudioHelper.stopMusic();
return true;
}
});
table.add(newGameButton).spaceBottom(BUTTON_SPACE);
table.row();
然而,"setDisabled(true)" 函数似乎没有起作用。有其他的方式可以完成这个任务吗?
TextButtonStyle
上有一个disabledFontColor
属性,您可以将其设置为不同的颜色,以在setDisabled(true)
时视觉上看到更改。 - Terry Deng