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 trialArunjit Oberoi
163 PointsDoing this in eclipse and encountering an error.
Firstly. The line at line #9 says public class MainActivity extends ActionBarActivity instead of public class MainActivity extends Activity.
And secondly, I'm getting an error.
TextView answerLabel = (TextView) findViewById(R.id.textView1);
Button getAnswerButton = (Button) findViewById(R.id.button1);
These are the lines I added. I don't get the option to select TextView1 or button while I type R.id...
I also get 2 errors. on textView1 and button1. The errors are: button1 cannot be resolved or is not a field. 2 quick fixes available.
2 Answers
Harry James
14,780 PointsOk,
Firstly you will want to extend Activity instead of ActionBarActivity. You can do it as ActionBarActivity however, you'll need to modify your code a bit and make more super classes (As ActionBarActivity is a subclass of Activity).
As for your errors with the ids, try running a project clean. Click Project on your action bar and then hit Clean. You can clean just the CrystalBall project or all of your projects, it's up to you.
Let me know how it goes.
Jurgen de Vries
14,554 PointsIn your Screenshot it seems Eclipse fails at finding Activity already.
Try organizing your imports again (CTRL + SHIFT + O or on a Mac CMD + SHIFT + O)
Hope that helps
Arunjit Oberoi
163 PointsArunjit Oberoi
163 PointsWhy did it set to ActionBarActivity if I followed the steps in the video exactly?
Edit: okay so I changed it to Activity instead of ActionBarActivity which lead to a lot of errors (see link: http://i.imgur.com/IJox6ES.png)
Harry James
14,780 PointsHarry James
14,780 PointsEclipse and the Android Tools change a lot here and there and I guess this was a recent change.
Also, as Jurgen de Vries said, simply organising your imports should fix these errors.