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
Jasper Lamaker
1,422 PointsHelp needed with Animating Crystalball App
Hi there!
I'm stuck on animating the Crystalball App in Android. The problem is that I can't set the image resource to the animation file resource. I've put all the animation files in the file 'drawable-mdpi' and I'm using the vollowing code:
private void animateCrystalBall() {
ImageView crystalBallImage = (ImageView) findViewById(R.id.imageView1);
crystalBallImage.setImageResource(R.drawable.)
}
When I want to link to the animationfiles, I'm only able to select 'Ball01: int R.drawable'. Click here to see a printscreen of the problem.
Could a fellow android programmer advice me what I should do to solve this problem?
Help is much appreciated :)
Regards,
Jasper
2 Answers
Ben Jakuben
Treehouse TeacherIf ever you are unable to find things through the R class (R.drawable, R.id, etc.), it usually means that the R class isn't being regenerated based on your latest changes. "R" stands for resources and this class is generated by Eclipse each time you build your project.
There are a number of reasons why R might not be regenerating. It could be errors in an XML file or even a file name, or maybe even just a wonky day for Eclipse. Sometimes you can clean and rebuild your project or sometimes you can restart Eclipse. Try those and then look at this question on StackOverflow for help: http://stackoverflow.com/questions/2041083/how-to-regenerate-r-class
Let us know what you find! If you continue to have trouble, can you paste in the code for ball_animation.xml?
Jasper Lamaker
1,422 PointsHi Ben,
I appreciate your quick response!
After some fiddling around I managed to find the ´Clean´ option. Everything was fine after using it. Thank you for pointing it out, and keep up the good work.
Jasper