Skip to end of metadata
Go to start of metadata

Demonstrates how to use a Switch element.

Example App Source Location


You can find this example app in the Alloy repository under samples/apps/ui/switch. Check the instructions how to run these sample projects.

The appearance of a Switch control varies by platform:

  • On Android, a Switch object can be styled either as a checkbox or toggle button using the  Ti.UI.Android.SWITCH_STYLE_CHECKBOX property, as shown below. The checkbox style can optionally display a label next to the control.
  • On iOS, a Switch appears as an iOS on/off switch and doesn't have any text associated with it.

The following screenshots show the sample app running on Android and iOS.

The main index.xml view displays a default Switch control that appears on all platforms, a titled switch that appears on Android and mobile web, and a checkbox style switch that only appears on Android.


The main XML view's TSS file defines the initial value, titleOn and titleOff properties for the titled switch, and sets the style and title values of the checkbox-styled switch.


See also

  • No labels