Last active
August 17, 2017 09:53
-
-
Save AkshayChordiya/29588fdf9a13f8ff9ebbc9a57b57f495 to your computer and use it in GitHub Desktop.
DetailUserActivity with ViewModel - LiveData and transformations
This file contains 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 DetailUserActivity : LifecycleActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_detail) | |
// Get the ViewModel instance | |
val userViewModel = ViewModelProviders.of(this).get(UserViewModel::class.java) | |
userViewModel.setUserId(getSelectedUserId()) | |
userViewModel.getUser().observe(this, Observer { | |
// Update the UI with the user details | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment