Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. // The finished onCreate method
  2. @Override
  3. protected void onCreate(Bundle savedInstanceState) {
  4. super.onCreate(savedInstanceState);
  5. setContentView(R.layout.activity_main);
  6. mViewModel = ViewModelProviders.of(this).get(ScoreViewModel.class);
  7. displayForTeamA(mViewModel.scoreTeamA);
  8. displayForTeamB(mViewModel.scoreTeamB);
  9. }
  10.  
  11. // An example of both reading and writing to the ViewModel
  12. public void addOneForTeamA(View v) {
  13. mViewModel.scoreTeamA = mViewModel.scoreTeamA + 1;
  14. displayForTeamA(mViewModel.scoreTeamA);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement