CHAPTER 7: Making Apps Interactive: Intents, Event Handling, and Menus 221
object type and place more than one name after that declaration. This is done by using the comma
character as a delimiter between the name values, as is shown in Figure 7-6. You can code seven
TextView declarations and names using the following Java code:
TextView nameData, solarData, habitData, colonyData;
TextView popData, fleetData, shipsData;
Figure 7-6. Add an onOptionsItemSelected( ) method and consolidate TextView object declarations with commas
You could also have done this using one single line of Java programming logic, by using the
following format:
TextView nameData, solarData, habitData, colonyData, popData, fleetData, shipsData;
Next, collapse your five methods, as shown in Figure 7-6, and add the onOptionsItemSelected( )
method as follows:
public boolean onOptionsItemSelected( ) { ... }
Once you do this, you will get red error highlighting under this new method name, advising you that
you need a return statement. Click on the Add return statement option, which will add the return
false; Java statement for you. Later on, we will change this to return a true value; but for now, since
the method does not do anything, false, which means nothing has been processed, would be the
correct return value for the currently empty method.