Android How to Program Chapter 08 Solution Manual
Download file with the answers
Android How to Program Chapter 08 Solution Manual
1 file(s) 263.32 KB
If you are not a member register here to download this file
8 SpotOn Game App
Obj e c t i v e s
In this chapter you’ll:
■ Create a simple gamepp
that’s easy to code and fun to
play.
■ Goup animations that move
and resize ImageViews with
ViewPropertyAnimators.
■ Respond to animation
lifecycle events with an
AnimatorListener.
■ Process click events for
ImageViews and touch
events for the screen.
■ Use the thread-safe
ConcurrentLinkedQueue
collection from the
java.util.concurrent
package to allow concurrent
access to a collection from
multiple threads.
■ Use an Activity’s default
SharedPreferences file.
2 Chapter 8 SpotOn Game App
Self-Review Exercises
8.1 Fill in the blanks in each of the following statements:
a) View animations display a sequence of images.
b) You can listen for property-animation lifecycle events by implementing the interface
, which defines methods that are called when an animation starts, ends, repeats
or is canceled.
c) A configures animations for commonly animated View properties—alpha
(transparency), rotation, scale, translation (moving relative to the current location) and
location.
d) Class ViewPropertyAnimator was added to Android 3.1 to simplify property animation
for Views and to allow animation of multiple properties in .
8.2 State whether each of the following is true or false. If false, explain why.
a) (True/False) The property animation class PropertyAnimator calculates property values
over time, but you must specify an AnimatorUpdateListener in which you programmatically
modify the target object’s property values.
b) (True/False) Android 3.1 added the utility class ViewPropertyAnimator to simplify
property animation for Views and to allow multiple properties to be animated in sequence.
c) (True/False) When an Activity begins executing, its onCreate method is called. This is
followed by calls to the Activity’s onPause then onResume methods. Method onResume
is also called when an Activity in the background returns to the foreground.
by calls to the Activity’s onStart then onResume methods. Method onResume
is also called when an Activity in the background returns to the foreground.
Exercises
8.3 State whether each of the following is true or false. If false, explain why.
a) (True/False) Property animations can be used to animate any property of any object.
b) (True/False) You can use the ConcurrentLinkedQueue class from package java.
util.concurrent and the Queue interface to maintain thread-safe lists of objects that
can be accessed from multiple threads of execution in parallel.
8.4 Fill in the blanks in each of the following statements:
a) View animations allow you to change limited aspects of a View’s appearance,
such as where it’s displayed, its rotation and its size.
Exercises 3
b) With animation (package android.animation), you can animate any
property of any object—the mechanism is not limited to Views.
c) ValueAnimator subclass uses the target object’s set methods to modify the
object’s animated properties as their values change over time.
d) You can use the ConcurrentLinkedQueue class (from package java.util.concurrent)
and the Queue interface to maintain lists of objects that can be accessed
from multiple threads of execution in parallel.
e) Setting the attribute android:hardwareAccelerated to “true” allows the app to use
hardware accelerated , if available, for performance.
f) In addition, a ViewPropertyAnimator provides methods for setting an animation’s duration,
(to respond to animation lifecycle events) and TimeInterpolator
(to determine how property values are calculated throughout the animation).
Leave a reply