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
Joshua Schoen
900 PointsInteractive Story Error
In the Interactive Story Class. I followed along and learned a lot, but I ran into a problem half-way into it. Everything is fine but, I have 1 line of code that's a problem in my MainActivity Java.Class.
The Problem: Sorry, but I have no idea how to import attachments like images. On this Intent intent line. I have an error on the ----> (This, StoryActivity.class) It says, "Cannot resolve constructor".
I have no idea why, and I've searched on these fourms and haven't found anything. So I figured I would post something. Also, if you guys can tell me if I can somehow include attachments like screenshots that would be appreciated. It's probably some obvious way, and imma' feel like an idiot XD.
2 Answers
Stephen Bone
12,359 PointsHi Joshua
Can you copy over the code in your MainActivity.java and StoryActivity.java?
To do this wrap your code with 3 backticks (```) on the line before and after. If you specify the language as java after the first set of backticks, that'll help us with syntax highlighting.
I think I've found the line (below) you're referring to but assuming yours looks the same as mine I could do with seeing more of the code to try and identify the issue.
private void startStory(String name) {
Intent intent = new Intent(this, StoryActivity.class);
intent.putExtra(getString(R.string.key_name), name);
startActivity(intent);
}
Thanks Stephen
Joshua Schoen
900 PointsBen, thanks lol. But I inically had a lowercase, "t" but it somehow became "uppercased" ( If that's a word) Capitalized I guess you could say. Stephen I'm pretty sure I have the same code as you. And I tried what you said, but I seriously have on idea what the error is. It's the exact same code, Stephen. Thanks so much for helping though. I cannot screenshot so I don't know, how to really show the problem. on the " Intent intent = new intent(this, Storyactivity.class); On that line it says, "cannot resolve constructor."
Ben Jakuben
Treehouse TeacherIt may still be a casing issue. :) It's all about that case, bout that case (forgive me).
You typed in this: Intent intent = new intent(this, Storyactivity.class);
which has a lowercase "i" for "intent" (after new). The class name must always be uppercase. Only your variable name (which can be whatever you want) can be lowercase. Try this:
Intent storyIntent = new Intent(this, StoryActivity.class);
I changed the variable name to hopefully make it more clear what is happening in this line.
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherAs Stephen requested, copy your code in and we can help troubleshoot. One possibility is that the error you typed has a capital "T" for "This", which should actually be all lowercase:
thisYour question shows:
(This, StoryActivity.class)Should be:
(this, StoryActivity.class)