Kotlin View setEnabled函数丢失? [英] Kotlin View setEnabled function missing?
本文介绍了Kotlin View setEnabled函数丢失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在科特林中,当使用kotlinx.android.synthetic
访问View
(例如Button
)时,缺少setEnabled()
功能吗? isEnabled()
功能仍然存在.
In Kotlin, when using kotlinx.android.synthetic
to access the View
(e.g. Button
), the setEnabled()
function is missing? The isEnabled()
function is still there.
我怎么setEnabled()
?
推荐答案
如所述在参考文献中,使用以下逻辑,将Java getter和getter和setter对在属性中表示为Kotlin:
As said in the reference, Java getters and pairs of getter and setter are represented as properties in Kotlin, using the following logic:
-
T getSomething()
(+void setSomething(T)
)→something: T
-
T isSomething()
(+void setSomething(T)
)→isSomething: T
T getSomething()
(+void setSomething(T)
) →something: T
T isSomething()
(+void setSomething(T)
) →isSomething: T
如果有塞特犬,从Kotlin可以看到var
-属性,否则它是不可修改的val
.
If there is a setter, a var
-property is seen from Kotlin, otherwise it's an unmodifiable val
.
使用isEnabled = value
代替setEnabled(value)
.
这篇关于Kotlin View setEnabled函数丢失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文