CHAPTER 15: Developing for Android Wearable Devices 587
Figure 15-44. Call a .setOnTouchListener( ) method off the marsIcon ImageView object via Eclipse pop-up helper
Next, type the new keyword, the View class name, and a period inside the .setOnTouchListener( )
parameter area. When the pop-up helper dialog appears, select a View.OnTouchListener( )
anonymous inner type-android.view option, which will create the inside of the OnTouchListener( )
structure. Then, simply add a method call to the .setBackgroundResource( ) method off of the
planetClock AnalogClock object inside of the onTouch( ) method, as shown in Figure 15-45. The
Java code structure should look like the following code:
marsIcon = (ImageView)findViewById(R.id.marsIcon);
marsIcon.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
planetClock.setBackgroundResource(R.drawable.marstime);
return false;
}
});