嗨,下面给出的是我的代码,我的按钮应该变得不可见但是INVISIBLE无效
fun onPlay(view: View){
var play = findViewById(R.id.play) as Button
play.isClickable=false
play.visibility=view.INVISIBLE
}
答案 0 :(得分:26)
您的代码中存在错误,可见性常量应该从Class变量设置,而不是从参数变量设置。通过View.INVISIBLE更改view.INVISIBLE
fun onPlay(view: View){
var play = findViewById(R.id.play) as Button
play.isClickable=false
play.visibility= View.INVISIBLE // v letter should be capital
}
答案 1 :(得分:3)
使用play.visibility=View.VISIBLE
可见,使用play.visibility=View.GONE
隐藏或隐藏