Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Last active September 7, 2023 04: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 codeforfun-jp/0e738d2205ce4136bcb29af10d750569 to your computer and use it in GitHub Desktop.
Save codeforfun-jp/0e738d2205ce4136bcb29af10d750569 to your computer and use it in GitHub Desktop.
How to Use View Binding with Java & Kotlin - 6
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.btn.setOnClickListener {
binding.message.text = "こんにちは"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment