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 trialSiddharth Saravanan
1,208 PointsStuck on code challenge! Please help I watched the video a billion times and I still cant get it!
I am stuck on task 2 of 4 in the "Animating the Crystal Ball" code challenge. Here is the code I thought would work for this code challenge(2 of 4).
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 {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void animateFrog() {
ImageView frogImage = (ImageView) findViewById(R.id.frog);
AnimationDrawable jumpAnimation = (AnimationDrawable) frogImage.getDrawable();
if (jumpAnimation.isRunning()) {
jumpAnimation.stop();
}
jumpAnimation.start();
}
If anyone can help please help!
2 Answers
Tommy Gebru
30,164 PointsHere try this out,
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 {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void animateFrog() {
ImageView frogImage = (ImageView) findViewById(R.id.frog);
AnimationDrawable jumpAnimation = (AnimationDrawable) frogImage.getDrawable();
}
}
Tommy Gebru
30,164 Pointsglad to help!
Siddharth Saravanan
1,208 PointsSiddharth Saravanan
1,208 PointsThank you so much it worked!