Android Programming Tutorials

(Romina) #1
Menus and Messages

Figure 16. The LunchList option menu, displayed, with one menu choice

Step #4: Show the Notes as a Toast.....................................................


Finally, we need to get control when the user selects the Raise Toast menu


choice and display the notes in a Toast.


The problem is that, to do this, we need to know what restaurant to show.


So far, we have not been holding onto a specific restaurant except when we


needed it, such as when we populate the details form. Now, we need to


know our current restaurant, defined as the one visible in the detail


form...which could be none, if we have not yet saved anything in the form.


To make all of this work, do the following:



  1. Add another data member, restaurant current, to hold the current
    restaurant. Be sure to initialize it to null.

  2. In onSave and onListClick, rather than declaring local restaurant
    variables, use current to hold the restaurant we are saving (in


61
Free download pdf