Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created Sep 5, 2021
Embed
What would you like to do?
How to Use View Binding with Kotlin - 4
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// setContentView(R.layout.activity_main)
binding = ActivityMainBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
binding.btn.setOnClickListener {
binding.myTextView.text = "こんにちは"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment