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

shivkumar loka
shivkumar loka
4,066 Points

Crystal Ball Animation Android.

After copying all the files in the CrystalBall Animation.zip and looking at the animation_ball.xml, I create a private method in the MainActivity class but I do not find all the pictures in R.java(ball_animation, ball01, ball02 and so on.....) when I try to add ball_animation.xml as the ImageView resource. Please help.

5 Answers

Hi Shivkumar!

I've notified the Teaching team that you need help :) stay tuned!

In the mean time, if you have any questions feel free to email us at help@teamtreheouse.com

Best,

Elizabeth

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

@Shivkumar, can you answer a few questions for me?

  1. Do the images show up in your Package Explorer under the "drawable-mdpi" folder? i.e. ball01.png, ball02.png, and so on, as well as ball_animation.xml

  2. What do you mean that you can't find them in R.java? Are you opening up the R.java file to look for the references, like this?:

public static final class drawable {
    public static final int ball01=0x7f020000;
    public static final int ball02=0x7f020001;
  1. Do you get some kind of error or warning in Eclipse when trying to set the image resource in this line?:
crystalBallImage.setImageResource(R.drawable.ball_animation);
shivkumar loka
shivkumar loka
4,066 Points
  1. The images are shown in the drawable-mdpi in the package explorer (all images including the xml file ball_animation.xml).
  2. I dont find the same in R.java like : public static final class drawable { public static final int ball01=0x7f020000; public static final int ball02=0x7f020001;.....
  3. using eclipse intellisense when I hit Command+space after R.drawable I should be able to see ball_animation in the options, but I did not.
  4. and if I type in ball_animation after R.drawable like R.drawable.ball_animation, the error message is (ball_animation cannot be resolved or is not a field) and upon clicking for solutions I have: create field ball_animation in type Drawable. But I noted that R.java is generated and is not to be modified.

Please help. Thank you Shivkumar

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

It sounds like your R class is not getting regenerated for some reason. Please try the following and let me know if it fixes this for you.

  1. Right-click on your project (the top Crystal Ball folder) in the Package Explorer in Eclipse. Select Refresh (near the middle of the menu).
  2. From the top menu, select Project > Clean.
  3. Either "Clean all projects" or make sure your Crystal Ball project is selected and click OK.
  4. If your project builds automatically, then take a look at R.java and see if the resources now show up. If not, you'll have to build the project (Project > Build Project).

Hi Ben/shivkumar,

I ran into this problem also and I found that the best way to add new files to a project is to just right-click on the drawable-mdpi folder and Import the files. They weren't cleanly being added via Finder.

Hope that helps someone,

-Mac