A (175)

(Tuis.) #1

376 CHAPTER 10: Android Animation: Making Your UI Designs Move


SetUp an ImageView: Assigning an ID Parameter


Before we can use this UI widget in Java program logic, we will need to add an
android:id value to it, which we can use to reference it from inside of the Java programming logic
which we are about to create in the next section of the chapter. This parameter is shown at the top
of the seen in Figure 10-13.


Figure 10-13. Add an android:id parameter and name the ImageView animImageView so you can reference it in Java


Figure 10-14. Declare an ImageView object and name it animImageView at the top of your MainActivity.java file


Since the UI elements already have ID values, this is all you have to add in your
activity_main XML file, so we are ready to get into some fairly extensive Java coding next, to make
the UI design functional.


Java Coding: Tying Your UI Together Using Java


Since the is central to everything that we will be doing over the rest of this chapter,
let’s declare an ImageView object named animImageView at the top of your MainActivity class,
under the TextView objects, as shown in Figure 10-14.

Free download pdf