Skip to content

Instantly share code, notes, and snippets.

@hafizrahman
Created December 29, 2019 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hafizrahman/b5cdad776367124ee870f357b5d23476 to your computer and use it in GitHub Desktop.
Save hafizrahman/b5cdad776367124ee870f357b5d23476 to your computer and use it in GitHub Desktop.
Example of View Binding using Kotlin Extension
// Using R.layout.activity_main from the 'main' source set
import kotlinx.android.synthetic.main.activity_main.*
class MyActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Instead of findViewById<TextView>(R.id.textView)
textView.setText("Hello, world!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment