Adding Animation

Our aim in this example is to add animation to the ListView shown in Figure 6-5. To do that, you need a class that derives from android.view.animation.Animation. You then need to override the applyTransformation method to modify the transformation matrix. Call this derived class ViewAnimation. Once you have the ViewAnimation class, you can do something like this on the ListView class:

ListView lv = (ListView)this.findViewById(; lv.startAnimation(new ViewAnimation());

Let us go ahead and show you the source code for ViewAnimation and discuss the kind of animation we want to accomplish (see Listing 6-16).

Listing 6-16. Code for the ViewAnimation Class public class ViewAnimation extends Animation {

public ViewAnimation2(){} ^Override

0 0

Post a comment