-
-
Save udacityandroid/797532fc79eed21d801e to your computer and use it in GitHub Desktop.
Android Development for Beginners : Cola Wars Example
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
public class MainActivity extends AppCompatActivity { | |
... | |
public void voteUdacicola(View view) { | |
int udacicolaVotes = 0; | |
udacicolaVotes = udacicolaVotes + 1; | |
} | |
public void votePepcity(View view) { | |
int pepcityVotes; | |
pepcityVotes = pepcityVotes + 1; | |
} | |
public void showMeVotes(View view) { | |
display(udacicolaVotes + " vs. " + pepcityVotes); | |
} | |
... | |
} |
@Kukkulum
A global variable is initialized at the starting of the code it is global means other methods can be used this variable but local variable is initialized inside a method and there local members can used it not all the methods.
Thank you for your explanation. It is helpful to understand the difference.
best android course on this planet
very nice course
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
**public void display(int p) {
TextView t1 = (TextView) findViewById(R.id.cocacola);
t1.setText("" + p);
}
the error is on de above code