Last active
August 17, 2017 09:36
-
-
Save AkshayChordiya/13cb237b3dbda8643bb6b8f70d078cd2 to your computer and use it in GitHub Desktop.
Main Activity with ViewModel instance and LiveData observe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : LifecycleActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
// Get the ViewModel instance | |
val userViewModel = ViewModelProviders.of(this).get(UserViewModel::class.java) | |
userViewModel.getUsers().observe(this, Observer { | |
// Update the UI | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment