SwitchPropertyView - shannah/CodeRAD GitHub Wiki

SwitchPropertyView

<radSwitch>javadoc

Synopsis

A wrapper for Switch, the binds to a view property.

Usage

<radSwitch tag="..."/>

Attributes

tag

A tag for the view property to bind to.

component.*

Set properties of the embedded com/javadoc/com/codename1/components/Switch.html[Switch].

Example

The following example creates a boolean view property named advancedOptions, then creates a <radSwitch> that binds to this property. The advancedOptions property is also bound to the hidden property of a container, so that the container will be hidden or shown by setting the switch on or off.

<?xml version="1.0"?>
<y xsi:noNamespaceSchemaLocation="RADSwitchSample.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <title>RADSwitch Sample</title>


    <define-tag name="advancedOptions" type="boolean"/>
    <border>
        <label layout-constraint="west">Show Advanced</label>
        <radSwitch layout-constraint="east" tag="advancedOptions"/>
    </border>

    <y bind-hidden="java:!${advancedOptions}.bool" rad-transition="hidden 0.3s">
        <label>Advanced Options</label>
        <spanLabel>Here are some advanved options that you may or may not want to set</spanLabel>
        <textField hint="enter option"/>
    </y>
</y>
RADSwitchSample1
Figure 1. When switch is selected, the "Advanced Options" panel is shown
RADSwitchSample2
Figure 2. When switch is not selected, the "Advanced Options" panel is hidden
⚠️ **GitHub.com Fallback** ⚠️