Skip to content

Instantly share code, notes, and snippets.

@hiteshchopra11
Last active December 11, 2021 10:52
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 hiteshchopra11/3d35b7b0bb5bb755eba7a49866431c63 to your computer and use it in GitHub Desktop.
Save hiteshchopra11/3d35b7b0bb5bb755eba7a49866431c63 to your computer and use it in GitHub Desktop.
val viewModel = MainActivityViewModel()
findViewById<Button>(R.id.btn_increment).setOnClickListener {
viewModel.incrementByOne()
}
viewModel.counterLiveData.observe(this) { counter ->
findViewById<TextView>(R.id.tv_counter).text = "$counter"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment