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 trialdanielaponader
7,689 PointsProblem with cast
Hello, thanks for any help! my app doesnt run. I am getting the following error:
ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView
Here is my code: final TextView factLabel= (TextView) findViewById(R.id.factTextView); Button showFactButton=(Button)
the (TextView) cast seems to be wrong but what else can I do. It is as taught in the video. Also in the XML i checked that my factTextView is as it should
1 Answer
Alice Spencer
12,273 PointsCan you post (roughly) lines 30-45 in your funfactsactivity.java file and the relative layout code from your xml? Use the markdown cheat sheet to show you how if you need to.
My first thought, is did you use autocomplete or did you hard code? I've notice AS seems to be a bit fussy in that regard and really prefers to autocomplete.