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
Harsha Rao
288 PointsProblem with Code Challenge: Animating the Crystal Ball
Hi, I'm having a bit of trouble with part 3 of the Code Challenge: Animating the Crystal Ball. The question is copied in quotation marks below, and my code follows. I'm not sure what the error is here? Thanks!
"Continuing with animateFrog(), add an if statement to see if jumpAnimation is currently running, but don't do anything inside the curly braces yet. Remember that the condition to test goes inside parenthesis after the 'if' keyword. Use the 'isRunning()' method of the jumpAnimation variable."
public void animateFrog(){
ImageView frogImage = (ImageView) findViewById(R.id.frog);
AnimationDrawable jumpAnimation = (AnimationDrawable) frogImage.getDrawable();
if(jumpAnimation.isRunning()){
};
};
3 Answers
Ernest Grzybowski
Treehouse Project ReviewerI'm pretty sure your code has a few too many semicolons.
I believe that challenge went something like this:
public void animateFrog(){
ImageView frogImage = (ImageView) findViewById(R.id.frog);
AnimationDrawable jumpAnimation = (AnimationDrawable) frogImage.getDrawable();
if (jumpAnimation.isRunning()){
}
}
That should be all you need. Simply remove the two semicolons you have. Let me know if you need anymore help.
Brandon C
3,091 PointsI'm having trouble as well, I have my code exactly like this:
public void animateFrog() {
ImageView frogImage = (ImageView) findViewById(R.id.frog);
AnimationDrawable jumpAnimation = (AnimationDrawable) frogImage.getDrawable();
if (jumpAnimation.isRunning()){
}
}
Nothing happens, still says: Compilation Error! Remember the syntax for an if statement: if (condition) { // code }
Don't know what the hell I'm doing wrong... I'm stuck.
Dan Giles
2,243 PointsI was having this problem at first also; it turned out to be missing one closing curly bracket "}"
If you take a look at Ernest's code above, there should be three closing curly brackets:
1- to close the if (jumpAnimation.isRunning()) statement 2- to close the animateFrog method 3- to close the MainActivity class
Tre Cameron
357 PointsTre Cameron
357 PointsHey, I tried doing exactly what you did , and i even tried copy and pasting it in, but it still says "Compilation Error! Remember the syntax for an if statement: if (condition) { // code }" , Please help, Im stuck, i dont know what im doing wrong.
Ernest Grzybowski
Treehouse Project ReviewerErnest Grzybowski
Treehouse Project ReviewerCan you post your entire code that you're trying? Even if you are "copying and pasting it in". We might be able to spot something simple that is off. =)
Terence Starzl
351 PointsTerence Starzl
351 PointsI'm having the same problem as them
package com.example;
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.ImageView; import android.graphics.drawable.AnimationDrawable;
public class MainActivity extends Activity {
public void animateFrog(){
} }
Ernest Grzybowski
Treehouse Project ReviewerErnest Grzybowski
Treehouse Project ReviewerI'm not sure if the spacing you are adding is throwing off the challenge system.
This code works... so hopefully you can compare your code with it.