CHAPTER 10: Android Animation: Making Your UI Designs Move 381
The easiest way to create these event handling structures is to copy one of the event handling
structures from your EditGalaxy.java Activity subclass and paste it under the five instantiation lines of
code for the ImageView, Animation, and ImageButton objects, as shown in Figure 10-21.
Figure 10-21. Add View.OnClickListener( ) event handling structures to each of the three ImageButton objects
- Copy the colonyButton event handler structure, change colonyButton to
imageButtonOne, and delete the Java code on the inside of the onClick( )
method, so that you have an empty event handling structure ready for your
ImageButton elements. - Copy this empty structure two more times beneath it, and change
imageButtonOne to imageButtonTwo and ImageButtonThree. The final Java
code structure should look like the following, and is shown installed in the
code in Figure 10-21:
imageButtonOne.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { Java code will go in here to switch Animation assets
and TextView info }
});