O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required