5.6.4. Method updateGuessRows
Method updateGuessRows (Fig. 5.28) is called from the app’s MainActivity when the app is launched and each time the user changes the number of guess Buttons to display with each flag. Lines 110–111 use the method’s SharedPreferences argument to get the String for the key MainActivity.CHOICES—a constant containing the name of the preference in which the SettingsFragment stores the number of guess Buttons to display. Line 112 converts the preference’s value to an int and divides it by 3 to determine the value for guessRows, which indicates how many of the guessLinearLayouts should be displayed—each with three guess Buttons. Next, lines 115–116 hide all of the guessLinearLayouts, so that lines 119–120 can show the appropriate ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access