Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The finished onCreate method
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- mViewModel = ViewModelProviders.of(this).get(ScoreViewModel.class);
- displayForTeamA(mViewModel.scoreTeamA);
- displayForTeamB(mViewModel.scoreTeamB);
- }
- // An example of both reading and writing to the ViewModel
- public void addOneForTeamA(View v) {
- mViewModel.scoreTeamA = mViewModel.scoreTeamA + 1;
- displayForTeamA(mViewModel.scoreTeamA);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement