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 trialTerence Evans
1,870 PointsCopy of text
Is there somewhere that I can go and download the text that is supposed to actually be in the different tabs such as MainActivity, StoryActivity, activity_story, etc. I must have made an error in doing the Main Activity as I am unable to get the START YOUR ADVENTURE button does nothing when activated.
5 Answers
Kristian Terziev
28,449 PointsYes. You can go below the video to the tab that says Download. From there you can download the project, open it and copy everything you need.
Terence Evans
1,870 PointsThanks so much for the help. I went through it and it all appears to be correct. I noticed that his AndroidManifest had a lot of red words. The other thing I noticed is that where he had typed "@string/app_name" I got "Interactive Story" which when I hover over gives me the "@string/app_name" so I assume it is Android Studio doing it's thing.
Kristian Terziev
28,449 PointsNot exactly. In the project tree you can see you have a folder named "res". Inside there is another one called "values". Finally inside that one there's a .xml file named "strings". When you open it, you will find numerous strings defined. One of them should be something like this:
<string name="app_name">Interactive Story</string>
That means, every time you use @string/app_name it will be viewed as "Interactive Story". But why can't we just type it for ourselves? Well imagine you have a database full of items - let's say 200. And now image that 100 of those items are from the same manufacturer. And when you need to change it, you would have to go to every single one of them and change it's value. You can see how it's quite easy to miss one and make a mistake. However, if you use the strings.xml you'll have to change the value of the manufacturer once and it will change everywhere.
Terence Evans
1,870 PointsI'm still stuck. The only thing I think it might be is the mStartButton statement - it is highlighted in orange and the notation says the field can be converted to a local variable.
Kristian Terziev
28,449 PointsCan't do much without you posting your code for us, sorry.
Terence Evans
1,870 PointsSorry. Here goes: In the MainActivity.java file, I have: package com.example.twesq.interactivestory;
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText;
public class MainActivity extends Activity {
private EditText mNameField;
private Button mStartButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mNameField = (EditText)findViewById(R.id.nameEditText);
mStartButton = (Button)findViewById(R.id.startButton);
mStartButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = mNameField.getText().toString();
startStory();
}
});
}
private void startStory() {
Intent intent = new Intent(this, StoryActivity.class);
startActivity(intent);
}
}
Is there any more code I should copy and paste?
Kristian Terziev
28,449 PointsWhat is your problem exactly? Can you copy the error you get when you try to run the app?
As for the orange message, click the text, hit Alt+Enter and quickfix it. Please review how to post your code because it's hard to read in the way you provided it.
https://teamtreehouse.com/forum/howto-guide-markdown-within-posts
Terence Evans
1,870 PointsSorry for the delay. I can't actually see an error. When you are writing about "markdown" are you referring to the 3```s? In the info I looked up it seems to say that doing this will give me the same dark box I am getting. What am I missing this time?
Kristian Terziev
28,449 PointsAfter the 3 s write java. So <new line>
java <code> ``` <new line>. It's very hard to read the code like that.
Also to the same and copy your log when you try to launch the app (that's the thing showing the errors)
Terence Evans
1,870 PointsSorry. Here is what is showing in my "logcat" which is what I think you mean when you say error log.
06-17 22:21:04.208 1019-1019/com.example.twesq.interactivestory D/dalvikvm﹕ GC_FOR_ALLOC freed 73K, 11% free 3206K/3596K, paused 162ms, total 163ms 06-17 22:21:04.388 1019-1019/com.example.twesq.interactivestory I/dalvikvm-heap﹕ Grow heap (frag case) to 8.586MB for 5400016-byte allocation 06-17 22:21:04.578 1019-1028/com.example.twesq.interactivestory D/dalvikvm﹕ GC_FOR_ALLOC freed <1K, 5% free 8479K/8872K, paused 182ms, total 182ms 06-17 22:21:05.828 1019-1019/com.example.twesq.interactivestory D/﹕ HostConnection::get() New Host Connection established 0xb81f09b0, tid 1019 06-17 22:21:05.948 1019-1019/com.example.twesq.interactivestory W/EGL_emulation﹕ eglSurfaceAttrib not implemented 06-17 22:21:05.958 1019-1019/com.example.twesq.interactivestory D/OpenGLRenderer﹕ Enabling debug mode 0
I hope this helps.
Terence Evans
1,870 PointsTerence Evans
1,870 PointsAt the risk of sounding like a total idiot, how do I do that? I downloaded the file, then I went to InteractiveStory, then which one(s) do I choose?
Kristian Terziev
28,449 PointsKristian Terziev
28,449 PointsThere's no such thing as sounding as idiot when it comes to things as this. You can't know things you didn't learn.
Anyway, so you download the InteractiveStory_s2v1.zip (or whatever the name). Then you open Android Studio and simply open the folder you extracted (Interactive Story). When you try to open it through Android Studio it should recognize it as a project. Open it in new window (it will ask you) and just find the classes you need, switch back to your code and compare it.
One last thing, I strongly advice you to not copy code. Write it on your own. Review it. Analyze it. What does each individual line do? Why is it needed? You should know what you're doing and if you do so, hopefully you will find what your mistake was (unless it was something small/technical)
Happy coding :)