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

Joshua Friedman
Joshua Friedman
537 Points

Pretty Little Things code challenge throws syntax errors--why?

The private void below throws syntax errors, pointing specifically at the first dot in R.drawable.frogImage.

If I delete that line, the challenge tells me "don't forget to define animateFrog()!"

What is my error here, because I can't find it?

Thank you!

  private void animateFrog(){
    ImageView frogImage = (ImageView) findViewById(R.id.frog);
    frogImage.setImageResource(R.drawable.frogImage);
    AnimationDrawable frogAnimation = (AnimationDrawable) frogImage.getDrawable();
    frogAnimation.start();

2 Answers

Daniel Hartin
Daniel Hartin
18,106 Points

Hi there,

It appears you have got a little ahead of yourself. Task 1 asks you to create the new method which you have done but are missing a closing curly brace (unless it is not pasted on screen and you have declared the method as private not public).

Task 2 asks you to create the AnimationDrawable variable jumpAnimation (you must use this variable name).

Try the following:-

Public void animateFrog(){

ImageView frogImage = (ImageView) findViewById(R.id.frog);

AnimationDrawable jumpAnimation = (AnimationDrawable) frogImage.getDrawable();

}

Delete all other lines of your code.

I wont paste the answers for task 3 and 4 as I think it is better to have a go for yourself first to really cement the learning.

Hope this helps

Daniel

Joshua Friedman
Joshua Friedman
537 Points

AH!!!! That's where my mistake was, I made the method private!

Problem between chair and keyboard over here. Thanks for the help :)