Challenge: Dynamically Adjusting the Number of Columns

Currently, the number of columns displayed in the grid is fixed at three. Update your code to provide a dynamic number of columns so more columns appear in landscape and on larger devices.

A simple approach could involve providing an integer resource qualified for different orientations and/or screen sizes. This is similar to the way you provided different strings for different screen sizes in Chapter 17. Integer resources should be placed in the res/values folder(s). Check out the Android developer documentation for more details.

But providing qualified resources does not offer much in the way of granularity. For a more difficult challenge (and a more flexible implementation), ...

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.