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 trialMichael Nickey
Courses Plus Student 13,524 Pointsball_animation cannot be resolved or is not a field
When I put my code in Eclipse, ball_animation is not an acceptable field. The other ball images are not being seen either. Below is the code. Please help!!!
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();
}
5 Answers
Michael Nickey
Courses Plus Student 13,524 PointsI'll give it a go Timothy. Unfortunately though when I tried this last night (removing the files, re-adding them & removing imports/re-adding them with Command+O) the errors that I got were horrendous. The code looked like a suicidal hemophiliac even after replacing my code with the ones in the zip file.
I'm just going to start over, make sure that eclipse is up-dated in all areas and see what happens. Last swing for this at bat.
Timothy Boland
18,237 PointsYes, when importing other peoples projects into Eclipse, you never know what errors you're going to get...it depends on the project and your current setup....But DONT QUIT....this is just one of the pitfalls...its best to just Google each error you get...and make the recommended adjustments for each...the best results are usually from StackOverflow...and as you get more practice...you will start recognizing the errors and know what to do...For me personally, i didn't want these errors to get in the way of my learning, so instead of importing the attached projects in the lesson, i just code each lesson into my own project by hand....its better practice that way.
Paul Stevens
4,125 PointsHello, not sure if I can help, but I will give it a go. :)
Try looking in the res/drawable-mdpi folder. That is where we put our ball_animation.xml. Check that the file name ball_animation.xml doesn't have a spelling mistake in it's name. Other than that I am not sure, but I will paste my ball_animation.xml file for you incase that helps at all.
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true" >
<item
android:drawable="@drawable/ball01"
android:duration="41"/>
<item
android:drawable="@drawable/ball02"
android:duration="41"/>
<item
android:drawable="@drawable/ball03"
android:duration="41"/>
<item
android:drawable="@drawable/ball04"
android:duration="41"/>
<item
android:drawable="@drawable/ball05"
android:duration="41"/>
<item
android:drawable="@drawable/ball06"
android:duration="41"/>
<item
android:drawable="@drawable/ball07"
android:duration="41"/>
<item
android:drawable="@drawable/ball08"
android:duration="41"/>
<item
android:drawable="@drawable/ball09"
android:duration="41"/>
<item
android:drawable="@drawable/ball10"
android:duration="41"/>
<item
android:drawable="@drawable/ball11"
android:duration="41"/>
<item
android:drawable="@drawable/ball12"
android:duration="41"/>
<item
android:drawable="@drawable/ball13"
android:duration="41"/>
<item
android:drawable="@drawable/ball14"
android:duration="41"/>
<item
android:drawable="@drawable/ball15"
android:duration="41"/>
<item
android:drawable="@drawable/ball16"
android:duration="41"/>
<item
android:drawable="@drawable/ball17"
android:duration="41"/>
<item
android:drawable="@drawable/ball18"
android:duration="41"/>
<item
android:drawable="@drawable/ball19"
android:duration="41"/>
<item
android:drawable="@drawable/ball20"
android:duration="41"/>
<item
android:drawable="@drawable/ball21"
android:duration="41"/>
<item
android:drawable="@drawable/ball22"
android:duration="41"/>
<item
android:drawable="@drawable/ball23"
android:duration="41"/>
<item
android:drawable="@drawable/ball24"
android:duration="41"/>
<!-- Reset to original -->
<item
android:drawable="@drawable/ball01"
android:duration="10"/>
</animation-list>
Hope this helps. :D
Michael Nickey
Courses Plus Student 13,524 PointsThanks Paul,
I appreciate this but unfortunately this doesn't help since we copied the filed from a zip and dragged it into the folder. I did check just to make sure and there were no spelling mistakes (which is unusual for me).
I will paste a screenshot if someone can tell me how without having to upload it to a third party server.
Timothy Boland
18,237 Pointsthis is a common problem in eclipse when you import a project instead of creating it from scratch...try removing the imports and hit Ctrl+O and have them reloaded.