CHAPTER 10: Android Animation: Making Your UI Designs Move 377
- Mouse-over the error highlight and select the Import ‘ImageView’ (android.
widget) option to have Eclipse write an import statement for you so that you
can use the ImageView class in your code. - Next, instantiate this animImageView object inside of your on Create( )
method, as seen in Figure 10-15, so that Android will create the object when
the application MainActivity starts. Reference yourwidget XML
definition using a findViewById( ) method, using the R.id.animImageView
reference path and ID value. Notice that you can use the same naming
values for the XML definition ID that you can for your Java object.
Figure 10-15. Instantiate the animImageView inside of the onCreate( ) method using the findViewById( ) method
- The next object that you will need to declare and instantiate will be the
Animation object which we will name spaceShipAnim, and which will
hold the transform data that you defined in the previous section of the
chapter. As you can see in Figure 1 0-1 6 , you will again need to mouse-over
the red error highlight and select the Import ‘Animation’ (android.view.
animation) option, so that Eclipse ADT will write your import statement
for you.