Developers
Local Navigation
Exercise
Create an application that can access the local address book.
Objectives
- Discover how to create an application that can access the local address book.
- See how to design the application to add a contact or view contact information from the address book.
Setup Tasks
- In the BlackBerry MDS Studio™, on the File menu, click New Project.
- Select the Top-Down Approach option.
- Click Next.
- In the Project name field, type Contact Viewer.
- Click Finish.
You can create an instance of the Contact data component from a screen by declaring a global variable or local variable of type Contact.
Tasks
Create a screen with a local variable
- In the Navigator pane, right-click Screens.
- Click New Screen.
- In the Name field, type scrContact.
- Click Finish.
- In the Screen Editor, click the screen canvas.
- In the Properties pane, in the Local Variables property, click ....
- Click +.
- In the Name cell, type contact to replace the default “address”
- In the Type drop-down list, select Contact.
Note: You can now assign screen controls to the screen local variable contact of the Contact built-in data component. - Click OK.
Create the screen controls
- In the Screen Editor, on the Screen Editor palette, click Region.
- Place the region control under the edit box.
- In the Properties pane, in the Layout property drop-down list, click Grid.
- On the Screen Editor palette, click Label.
- Place the label control in the region.
- In the Properties pane, in the click Caption property, click ....
- In the Caption field, type First name:.
- Click OK.
- Create an editBox control to the right of the label control in the region.
- In the Properties pane, in the Mapping property, click ....
- In the list of available data, expand Local Variables > contact.
- Click nameGiven.
- Click OK.
- Create label and editBox controls for the remaining contact information.
| Label caption | EditBox output mapping |
|---|---|
| Last name: | nameFamily |
| Email: | Email1 |
| Work: | workTel |
Tip: The default layout of the grid region is 2 by 2. To position a label control in the next row of the grid region, drag the control to the far right of the previous row. The BlackBerry MDS Studio positions the control on the next row.
Save the project
- In the Navigator pane, click the Contact Viewer project.
- On the toolbar, click Save.
Additional Labs
Go to the next exercise in “Creating a Length Conversion Application Using the Top-down Approach”, Display Contact Information.