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 trialHarry James
14,780 PointsCrash - TextView cannot be cast to button
Hello!
I'm having a bit of an issue with my app in the fact that I am unable to start it. I did a bit of Googling on the issue and found that if my code is TextView answerLabel = (Button) findViewById(R.id.textView1);
instead of
TextView answerLabel = (TextView) findViewById(R.id.textView1);
Then the error will occur.
//
The problem is, my code is like the bottom example and I can't understand what's causing the crash.
Here is my crash log: http://pastebin.com/tGfXktn3
Here is my MainActivity.java file: http://pastebin.com/kFa0MqrJ
Here is my activity_main.xml file: http://pastebin.com/mhPUgY9x
Any help would be much appreciated! :)
1 Answer
y0mki
14,218 PointsHi!
Could you please paste your acitivity_main.xml file here as well, that would help on finding the cause of your error.
Harry James
14,780 PointsHarry James
14,780 PointsI have now updated my previous post to include my activity_main.xml file.
Thanks in advance!
y0mki
14,218 Pointsy0mki
14,218 PointsHi Harry!
I didn't find any errors in your project, I actually tried to create your project on my workspace, and it ran just fine. What you could do is clean your project using Eclipse, by clicking on Project->Clean... If that doesn't show any results, you can try uploading your project and sending me the link, I'll have a look at it :-)
Harry James
14,780 PointsHarry James
14,780 PointsHello again!
Good news now, I have managed to track down the issue. It was in my AndroidManifest.xml.
I had my theme set to one that must no longer be supported by Android so, by updating it to Theme.base, I was able to fix the issue.
Appreciate your help anyway and for taking the time to find the issue (As, not everyone would do that).
y0mki
14,218 Pointsy0mki
14,218 PointsI'm glad that you solved the problem. This is why I love Treehouse, because everybody tries to help each other!