Last active
March 15, 2017 18:51
-
-
Save jasonkneen/b7c6f0cb61988d333092 to your computer and use it in GitHub Desktop.
Demo of how to use David Bankier's "Real Switch" for Android here. https://github.com/dbankier/RealSwitch. Add the Module to your TiApp.xml file, add a switch to your Alloy file as normal, but add the module attribute. Drop the ui.js file into your /lib/ folder (you can add to this) and then run the project. On iOS you'll get a regular iOS switc…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.mySwitch.addEventListener('change',function(e){ | |
Ti.API.info('Switch value: ' + $.mySwitch.value); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<Window> | |
<Switch id="mySwitch" module="ui"/> | |
</Window> | |
</Alloy> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.createSwitch = function(args) { | |
if (OS_ANDROID) { | |
var RealSwitch = require("com.yydigital.realswitch"); | |
return RealSwitch.createRealSwitch(args); | |
} else { | |
return Ti.UI.createSwitch(args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment