Specification: You will create a profile page where the user can add and edit their information. You will make the input methods relevant to the information being entered. Then that information will be saved as a profile for the user.
Download the starting files from this link and import it into Appclerator Studio. Make any necessary changes to tiapp.xml and the nodeACS server such as updating your API keys.
There are a number of different keyboard layouts to use, but since we are using an email address for signup, we’ll go with Ti.UI.KEYBOARD_EMAIL
This should be set as the value of the “keyboardType” property on the login TextField
A more comprehensive list of keyboard layouts can be found here http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.TextField-property-keyboardType
Sometimes having the screen scrollable behind the keyboard isn’t enough. In situations like these, an iOS keyboard toolbar done button is the tool for the job.
Split the “name” and “password” TextFields in login.xml into android- and iOS-specific versions (platform=’android’ and platform=’ios’ xml tags, respectively) and remove the forward slash closing the TextField on iOS
Inside these tags, add a <KeyboardToolbar> tag, and within that, add <Items>
<Items> contains any items you may want the keyboard toolbar to consist of.
For this exercise, we’ll be using FlexSpace and a Button titled “Done”
For more information on toolbars and concepts like FlexSpace, visit the docs at http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.iOS.Toolbar
Add a FlexSpace and a Button in that order (or else the button will be on the left, and not easily reachable by thumb for one-hand users)
Name the button what you like, and add a listener for click events (onClick=...)
Name the function run onClick something like “lowerKeyboard”
Repeat these steps for the password TextField, being sure to give the password’s done button the same click listener
In login.js, create a function to handle the click events from your keyboard toolbar done buttons
In the function, call the blur() method on both of those TextFields, to ensure that if either of them are focused, the keyboard will lower
You now have a KeyboardToolbar with a button that lowers the keyboard
Android devices have a hardware back button to handle lowering the software keyboard, but you can still control the way the app reacts to the keyboard’s presence
The Window property windowSoftInputMode determines how the app handles a keyboard appearing
- Learn more at http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Window-property-windowSoftInputMode
You can download the completed lab from this link.