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 Button
s 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 Button
s 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 Button
s. Next, lines 115–116 hide all of the guessLinearLayouts
, so that lines 119–120 can show the appropriate ...
Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.