Code the Toggle Button

Coding the toggle button is relatively easy, if not somewhat tedious. It is easy because you need only to enable or disable the interface. It is tedious because each widget that the user could interact with must be enabled or disabled separately. The ToggleButton's functionality requires the creation of three methods. One method will initialize the button to respond to the user. A second method will enable all the data entry widgets, and the third will disable all the widgets. First enter the code in Listing 4.9 after the navigation bar button code to initialize the ToggleButton. Remember to import any items underlined in red.

Listing 4.9 ToggleButton Initialization Method

private void initToggleButton() ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.