I am new in Titanium alloy and I would like to change my project from titanium default template to alloy. Below is the code for creating a text box in default template. I would like to change this to alloy template.
var checkbox = Ti.UI.createSwitch({
id:'checkbox',
style:Ti.UI.Android.SWITCH_STYLE_CHECKBOX,
});
Not hard at all! Try this inside your Alloy XML view markup:
checkbox.xml
<Alloy>
<Switch id="checkbox"/>
</Alloy>
Now we can use the style file to set attributes based on the id.
checkbox.tss
"#checkbox[platform=android]" : {
style:Ti.UI.Android.SWITCH_STYLE_CHECKBOX
}
This will set the style to checkbox, also note that I set this to only happen for android. Alternatively, if we wanted every switch to be of the checkbox style we could set this inside app.tss:
"Switch" : {
style:Ti.UI.Android.SWITCH_STYLE_CHECKBOX
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With