- Kotlin Standard Library Cookbook
- Samuel Urbanowicz
- 92字
- 2021-07-23 19:06:01
How to do it...
- Call the setOnClickListener function and pass an empty OnClickListener instance as a lambda expression:
class RegistrationScreen : Activity() {
private val submitButton: Button by lazy { findViewById(R.id.submit_button) }
override fun onCreate(savedInstanceState: Bundle?) {
submitButton.setOnClickListener { view: View ->
// do something on click
}
}
}
- Modify the visibility of the submitButton instance inside the function body:
class RegistrationScreen : Activity() {
private val submitButton: Button by lazy { findViewById(R.id.submit_button) }
override fun onCreate(savedInstanceState: Bundle?) {
submitButton.setOnClickListener {
submitButton.visibility = View.INVISIBLE
}
}
}
推薦閱讀
- Practical Data Analysis Cookbook
- 程序員修煉之道:程序設計入門30講
- AngularJS Testing Cookbook
- 程序員面試白皮書
- C++程序設計基礎教程
- Unreal Engine 4 Shaders and Effects Cookbook
- C程序設計實踐教程
- Mastering JavaScript Design Patterns(Second Edition)
- Python編程從0到1(視頻教學版)
- 零基礎趣學C語言
- 精通MySQL 8(視頻教學版)
- Zabbix Performance Tuning
- 大學計算機基礎
- Fastdata Processing with Spark
- PHP+MySQL動態網站開發從入門到精通(視頻教學版)