January 2014
Intermediate to advanced
736 pages
70h 43m
English
Lines 91–98 (Fig. 5.27) registered guessButtonListener (Fig. 5.33) as the event-handling object for each guess Button. Instance variable guessButtonListener refers to an anonymous inner class object that implements interface OnClickListener to respond to Button events. The method receives the clicked Button as parameter v. We get the Button’s text (line 259) and the parsed country name (line 260), then increment totalGuesses.
If the guess is correct (line 263), we increment correctAnswers. Next, we set the answerTextView’s text to the country name and change its color to the color represented by the constant R.color.correct_answer (green), and we call our utility method disableButtons ...
Read now
Unlock full access