Exercise -1
Create a Titanium project using both Studio and the Command Line Interface
Create a Titanium project using both Studio and the Command Line Interface
Solution
$ ti create -d /tiproject/newworkspace --id com.vmware.sample
Exercise -2
Run a Titanium project in the simulator/emulatorSolution$ ti create -d /tiproject/newworkspace --id com.vmware.sampleExercise -3Configure app properties such as the SDK version, target platformsExercise -4Pass Context Between Windows using CommonJSSolutionapp/lib/foo.js:// For a classic Titanium project, save the file to 'Resources/foo.js'vardata={};functionsetData(obj){data=obj;}functiongetData(){returndata;}// The special variable 'exports' exposes the functions as publicexports.setData=setData;exports.getData=getData;app/views/index.xml:<Alloy><WindowbackgroundColor="blue"><LabelonClick="openWindow">Open the Red Window!</Label></Window></Alloy>app/controllers/index.xml:varfoo=require('foo');foo.setData({foobar:42});functionopenWindow(){varwin2=Alloy.createController('win2').getView();win2.open();}$.index.open();app/views/win2.xml:<Alloy><WindowbackgroundColor="red"><Labelid="label">I am a red window.</Label></Window></Alloy>app/controllers/win2.js:varfoo=require('foo');$.label.text=foo.getData().foobar;Exercise -5Pass Context Between Windows using Alloy ControllerSolutionfunctionopenWindow(){var win2 =Alloy.createController('win2', {foobar: 42}).getView();win2.open();}For Alloy projects, you can also pass in contextwith theAlloy.createControllermethod and retrieveit in the controller code.var args = arguments[0] || {};$.label.text = args.foobar;
No comments:
Post a Comment