Creating Buttons and Labels using Events
So far, we've looked at a basic project and creating Windows and Views. Now, let's look at creating some Labels and Buttons and adding some click events.
How to do it...
Keep the index.xml
that you created for the last recipe. Let's modify it a little to add some labels and buttons. Change the code to the following:
<Alloy> <Window backgroundColor="white" layout="vertical"> <Label id="myLabel" borderRadius="2" top="40" borderColor="#CCC" height="35" width="200"/> <Button id="myButton" borderRadius="2" backgroundColor="#35e" color="#fff" top="10" height="35" width="100">Click me!</Button> </Window> </Alloy>
Build the app in the simulator to see the following:
Notice that we're using a vertical layout to make things easier, and we&apos...