Add the method to the like "onRadioButtonClicked" "LinearLayout.java" this (Figure 88); Figure 88: Event Handler for Radio Buttons This is how the completed UI look like in an AVD (Figure 89) Figure 89: CheckBoxes at work! Tip: Use when you want to show all the options to the Otherwise, RadioButton you should consider using instead. Spinner ToggleButton A is an on/off switch. It can be used in turning on and off features ToggleButton like vibration mode, silent mode, WiFi connection, and so on. We will add a to the page to toggle WiFi connection. ToggleButton LinearLayout Open the "activity_linear_layout.xml" in view, drag Design a widget from the and placed it below ToggleButton Palette the Set its and properties to "WiFi On" and RadioGroup. textOn textOff "WiFi Off" respectively (Figure 90) Figure 90: ToggleButton Open the "activity_linear_layout.xml" in view, Text assigned to the attribute. The "onToggleClicked" Android:onClick completed XML for the toggle button should look like that in Figure 91. Figure 91: ToggleButton in XML Add the method to the like this "onToggleClicked" "LinearLayout.java" (Figure 92);
Add the "onRadioButtonClicked" method to the "LinearLayout.java" like this (Figure 88); Figure 88: Event Handler for Radio Buttons This is how the completed UI look like in an AVD (Figure 89) Figure 89: CheckBoxes at work! Tip: Use RadioButton when you want to show all the options to the Otherwise, you should consider using Spinner instead. ToggleButton A ToggleButton is an on/off switch. It can be used in turning on and off features like vibration mode, silent mode, WiFi connection, and so on. We will add a ToggleButton to the LinearLayout page to toggle WiFi connection. Open the "activity_linear_layout.xml" in Design view, drag a ToggleButton widget from the Palette and placed it below the RadioGroup. Set its textOn and textOff properties to "WiFi On" and "WiFi Off" respectively (Figure 90) Figure 90: ToggleButton Open the "activity_linear_layout.xml" in Text view, assigned "onToggleClicked" to the Android:onClick attribute. The completed XML for the toggle button should look like that in Figure 91. Figure 91: ToggleButton in XML Add the "onToggleClicked" method to the "LinearLayout.java" like this (Figure 92);
Android%20UI%20and%20Controls%20New.docx