Creating a Switch

Changing Default Values

Both the text that the control displays for the ON and OFF states and
the default value are configurable. For example, to make the Switch
default to ON and read NO/YES instead of OFF/ON, we can set the
checked, textOn, and textOff attributes in the following XML.

When a Switch's value changes, it raises a CheckedChange event.
For example, in the following code we capture this event and present a
Toast widget with a message based upon the isChecked value of
Switch, which is passed to the event handler as part of the
CompoundButton.CheckedChangeEventArg argument.