我有在这一行重载歧义错误:
departureHourChoice!!.selectionModel.select(currentHourIndex)
以供参考:
departureHourChoice
是ChoiceBox<Int>
,这是从java.scene.control
currentHourIndex
是一个 Int
重载解析歧义发生在.select()
方法; 这是超载,并且可以接受两种参数:(T obj)
或(int index)
。
所述.select()
方法允许在一个项ChoiceBox
被选择,并且可以确定哪一个可以通过参照该项目或到它的索引来选择。在这种情况下,我希望它由指数(选择int
)。
一个人怎么就解决了重载解析歧义?
看来你被打到这个错误作为一种解决方法,您可以:
框currentHourIndex
:
lateinit var departureHourChoice: ChoiceBox<Int>
...
val currentHourIndex = 1
departureHourChoice.selectionModel.select(currentHourIndex as Int?)
或变更申报ChoiceBox
使用java.lang.Integer
,而不是科特林年代Int
:
lateinit var departureHourChoice: ChoiceBox<java.lang.Integer>
...
val currentHourIndex = 1
departureHourChoice.selectionModel.select(currentHourIndex)
延伸阅读:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句