Created
June 23, 2017 18:43
-
-
Save ceruleanotter/37114c9fb26c468ced0fa13e2e9ca3d7 to your computer and use it in GitHub Desktop.
ViewModel BlogPost : Part 1 : Step 3
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
// 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); | |
} |
@ TheRedSpy15 - Good question ! I was looking for the same.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where's the code for
displayForTeamA()
anddisplayForTeamB()
?