Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Crystal Ball Animation not Displaying on Emulator

I am trying to get the CrystalBall animation running. I followed all the steps, it works fine, except the background animation. I uploaded all the files to the specified drawable-mdpi folder. Here's my code for the background animation:

private void animateCrystalBall() {
    ImageView crystalBallImage = (ImageView) findViewById (R.id.imageView1);
    crystalBallImage.setImageResource(R.drawable.ball_animation);
    AnimationDrawable ballAnimation = (AnimationDrawable) crystalBallImage.getDrawable();
    if (ballAnimation.isRunning()) {
        ballAnimation.stop();
    }
    ballAnimation.start();

However, when I press the button, it just shows the second image.

3 Answers

Actually NVM,

I forgot to put in the code

animateCrystalBall();

in the Oncreate method

Haha. Forgive me, I'm still a beginner haha.

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Cool - glad you figured it out on your own! :smiley: :thumbsup:

Woohoo! :D