animation drawable

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

animation drawable

Postby kitox321 » Fri Jun 08, 2012 8:11 pm

hi there, i am a newbie in android dev...So I want my animation to start as soon as the activity is created, but for some reason no matter what I try will get it to start, it wont...

Here's what I have and how do I get this to work?



import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class Game extends Activity {
AnimationDrawable roadAnimation;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game);

ImageView roadImage = (ImageView) findViewById(R.id.roadimage);
roadImage.setBackgroundResource(R.drawable.roadanimation);
roadAnimation = (AnimationDrawable) roadImage.getBackground();

Button startbutton = (Button) findViewById(R.id.sgame_btn);

startbutton.setOnClickListener(new Button.OnClickListener(){

public void onClick(View arg0) {

// TODO Auto-generated method stub


roadAnimation.start();

}
});
kitox321
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Jun 08, 2012 7:40 pm

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests