access如何使某个控件无效

lewis 2018-05-23 22次阅读

使用isEnabled属性可以设置控件的有效性。将其设置为false将使控件无效。例如,如果要使一个Button控件无效,可以使用以下代码:

val button = findViewById<Button>(R.id.button)
button.isEnabled = false

或者,如果要使一个EditText控件无效,可以使用以下代码:

val editText = findViewById<EditText>(R.id.editText)
editText.isEnabled = false


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。