Java Kotlin刷新图像视图
我试图刷新按钮叮当声中imageview的图像,但它似乎不起作用。 这是我的密码:Java Kotlin刷新图像视图,java,android,kotlin,desktop-application,tornadofx,Java,Android,Kotlin,Desktop Application,Tornadofx,我试图刷新按钮叮当声中imageview的图像,但它似乎不起作用。 这是我的密码: class MasterView : View("Master View") { val controller: MyController by inject() val currentenemy = SimpleIntegerProperty(0) override val root = borderpane() { right = imagevie
class MasterView : View("Master View") {
val controller: MyController by inject()
val currentenemy = SimpleIntegerProperty(0)
override val root = borderpane() {
right = imageview(controller.monsters[currentenemy.value]) {
setFitHeight(250.0)
setFitWidth(175.0)
}
center = button("Change image") {
action { currentenemy.value += 1 }
}
}
}
我知道值在变化,但imageview似乎并不关心它。我不太明白它为什么会修复它,但我尝试将该值放入SimpleStringProperty中,并将该变量传递给imageview,现在在按钮单击时更新它
val simplestring = SimpleStringProperty("slime.png")
...
imageview(observablepic)
center = button("Change image") {
action {
currentenemy.value += 1
simplestring.value = controller.monsters[currentenemy.value]
}
}
...
val simplestring = SimpleStringProperty("slime.png")
...
imageview(observablepic)
center = button("Change image") {
action {
currentenemy.value += 1
simplestring.value = controller.monsters[currentenemy.value]
}
}
...
class MyController: Controller() {
val monsters = FXCollections.observableArrayList("slime.png", "goblin.png", "mage.png", "knight.png", "boss.png")
}