Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Titanium Mobile allows for the creation of both native and custom buttons. Starting with the app.js file in the 03 _02 folder of the exercise files, I've created a new window object. Next, I'll switch to the completed code and copy the code snippet for creating a new button. The Titanium.UI.createButton method creates a new button object. At a minimum, I have to supply dimension properties for the object or else the button will fill the entire screen. I've used the title property to display text on the button.
I've also added a custom property called id to the button object. I'll be retrieving this property with an EventListener in a moment. With the button object created, I'll add it to the window object. Now I'll add an EventListener to the button and listen for the click event. Within the click event I'll create a callback to fire an Alert dialog, that will a return string containing the source, object's ID property, and the type property of the event itself.
I'll cover Alert dialogs in more detail later in this course. Now I'll take a look at the result in the Simulator, when the button is clicked the Alert fires. Next, I want to create a button with a custom background. To do this I'll switch to the completed code and copy the code snippet for creating that button.
Now I'll add the paths to images to be used for the backgroundImage and backgroundSelectedImage state of the button. I'll add customButton to the window object. I'll copy code to add an EventListener that will fire with a touchend event. Now I'll take a look at the result in the Simulator. It's worth noting that the device will resize the image to fit the size of the button.
Next I'll add a slider control to the app to capture different sort of input.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98508 Viewers
61 Video lessons · 85800 Viewers
71 Video lessons · 69704 Viewers
56 Video lessons · 102010 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.