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 Build a Simple Android App (retired 2014) Pretty Little Things Animating the Crystal Ball

Animation Drawable

Please let me know what mistake i am making with the code below......

public void animateFrog() { ImageView frogImage = (ImageView) findViewById(R.id.frog); AnimationDrawable jumpAnimation = (AnimationDrawable) Image.getDrawable(frogImage); }

4 Answers

Aaron Arkie
Aaron Arkie
5,345 Points
public void animateFrog() { 

             ImageView frogImage = (ImageView) findViewById(R.id.frog); 
             AnimationDrawable jumpAnimation = (AnimationDrawable) Image.getDrawable(frogImage); 

}

Hello! i edited your code, check out how to do on the Markdown Cheatsheet just above the "Post answer" button.

Aaron Arkie
Aaron Arkie
5,345 Points

Okay you are so close and you are definitely on the right track! You put the frogImage object as the parameter for .getDrawable. But you are actually going to use this object to get what it stores (i believe they are pictures). So the following code should work, i hope this helps!

public void animateFrog() { 

             ImageView frogImage = (ImageView) findViewById(R.id.frog); 
             AnimationDrawable jumpAnimation = (AnimationDrawable) frogImage.getDrawable(); 

}

Thank you but I had already solved this problem..... But thanks for putting forth all the effort!!! :) @aaronarkie

Aaron Arkie
Aaron Arkie
5,345 Points

No problem im happy you solved it, good luck on the rest!:)