AnimationDrawable

Put your problem here if it does not fit any of the other categories.

AnimationDrawable

Postby izeko » Tue Mar 15, 2011 11:46 pm

Hi,
I am trying to get my animation 2 show 2 images one after another. The first displays ok, but the 2nd did not show.
I have read on the internet not to do this from the onCreate(), so thats when I have created a 2nd class and try to use this. Now i get nothing. Can someone tell me whats missing. code below:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class MainActivity extends Activity {
  2.  
  3.     CustomDrawableView mCustomDrawableView;
  4.  
  5.     /** Called when the activity is first created. */
  6.     @Override
  7.     public void onCreate(Bundle icicle) {
  8.         super.onCreate(icicle);
  9.         // ToDo add your GUI initialization code here
  10.  
  11.  
  12. mCustomDrawableView = new CustomDrawableView(this);
  13. setContentView(mCustomDrawableView);
  14.  
  15.     }
  16.  
  17.  
  18. public class CustomDrawableView extends ImageView {
  19.     private ShapeDrawable mDrawable;
  20.  
  21.     public CustomDrawableView(Context context) {
  22.         super(context);
  23.  
  24.  
  25.  
  26.         ImageView  imageView;
  27.         imageView= new  ImageView(context,null);
  28.  
  29.  
  30.  
  31.         AnimationDrawable sprite = new AnimationDrawable();
  32.         sprite.addFrame(BitmapDrawable.createFromPath
  33.         ("sdcard/image1.png"), 200);
  34.         sprite.addFrame(BitmapDrawable.createFromPath
  35.         ("sdcard/image2.png"), 200);
  36.         imageView.setImageDrawable(sprite);
  37.         sprite.start();
  38.     }
  39.  
  40.     protected void onDraw(Canvas canvas) {
  41.         //mDrawable.draw(canvas);
  42.         super.onDraw(canvas);
  43.         canvas.restore();
  44.     }
  45. }
  46.  
  47.  
  48.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Can someone help, thanks
izeko
Freshman
Freshman
 
Posts: 9
Joined: Mon Oct 11, 2010 11:46 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 22 guests