Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

2.

Right-click the newly added strings folder and choose


New→File. Name the new file strings.xml and click Finish. The
file will open in the editor.
3. Right-click in the editor window, and choose Add Child→New
Element. Name that element “strings” and click OK.
4. Right-click on the new “strings” element, and choose Add
Child→New Element. Name that element “string” and click OK.
5. Right-click on the new “string” element, choose Add
Attribute→New Attribute, and name it id. Set its value to
prompt. Right-click the “string” element again, choose Add
Child→#PCDATA;, then change the content of the newly added
child from “strings” to “Press/hold right button”.
6. Click File→Save to save strings.xml.

Next, run the project with the MyFirstApp_vivoactiveHR configura‐


tion, and you should see the new prompt appear.

A Tour of the Source Code


Let’s have a look at the code that makes this run.
In the source folder, there are four files that contain this app’s code.
All of the source code files contain a class, which contains several
methods. One of these, initialize(), calls the initialize()
method of its base class, and is present in all four files/classes.
MyFirstAppApp.mc
This is the entry point of your application. There are three addi‐
tional methods in here aside from initalize(): onStart(),
which gets called when the app first begins; onStop(), which is
called when the app runs; and getInitialView(), which sets up
the first view/screen you see when the app starts (in this case, a
Monkey with the text “Click the menu button”).
MyFirstAppDelegate.mc
This is the app’s delegate, which contains all the methods that
define the behavior of the app. This contains the onMenu()
method, which displays a menu when the device’s menu button
is pressed, or when another action takes place (such as long-
pressing the right button) that maps to the menu button action.

30 | Chapter 3: Getting Started with Connect IQ

You might also like