Challenge: Reporting the Device’s Android Version

Add a TextView widget to the GeoQuiz layout that reports to the user what API level the device is running. Figure 7.4 shows what the final result should look like.

Figure 7.4  Finished challenge

Finished challenge

You cannot set this TextView’s text in the layout, because you will not know the device’s Android version until runtime. Find the TextView function for setting text in the TextView reference page in Android’s documentation. You are looking for a function that accepts a single argument – a string (or a CharSequence).

Use other XML attributes listed in the TextView reference to adjust ...

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.