586 CHAPTER 15: Developing for Android Wearable Devices
Make sure to mouse over the wavy red error highlighting, so that Eclipse will import the ImageView
class for you.
Next, instantiate the AnalogClock and one of the ImageView objects using the findViewById( )
method. This will wire the object up to its XML UI definition, as shown in Figure 15-43, using the
following lines of Java coding logic:
planetClock = (AnalogClock)findViewById(R.id.earthAnalogClock);
marsIcon = (ImageView)findViewById(R.id.marsIcon);
Figure 15-43. Instantiate planetClock AnalogClock object and marsIcon ImageView object using findViewById( )
Next, you will add the event-handling structure to the marsIcon ImageView, and then you can copy
and paste that icon structure to create the other three, as they are quite similar in form and function.
Type the marsIcon object name and a period and then type “set” to find the setOnTouchListener( )
method from the pop-up dialog. Double-click on it to insert it as the method you are calling.
See Figure 15-44.