Updating the View Layer

Now that you have been introduced to MVC, you are going to update GeoQuiz’s view layer to include a NEXT button.

In Android, objects in the view layer are typically inflated from XML within a layout file. The sole layout in GeoQuiz is defined in activity_main.xml. This layout needs to be updated as shown in Figure 2.5. (Note that to save space we are not showing the attributes of unchanged widgets.)

Figure 2.5  New button!

New button!

So the changes you need to make to the view layer are:

  • Give the TextView an android:id attribute. This widget will need a resource ID so that you can set its text in MainActivity ...

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.