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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Alice Spencer](https://secure.gravatar.com/avatar/7b9d27030d643890be6acad25f819655?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Alice Spencer
12,273 PointsName field not being returned in storry
This has me stumped. I have added
<string name="key_name">name</string>
to my strings.xml file
mStartButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = mNameField.getText().toString();
startStory(name);
}
});
}
private void startStory(String name) {
Intent intent = new Intent(this, StoryActivity.class);
intent.putExtra(getString(R.string.key_name),name);
startActivity(intent);
}
to my MainActivity.java file
and
mName = intent.getStringExtra(getString(R.string.key_name));
to my StoryActivity.java file
BUT...when I run the program and enter my name, the next page, which is the first page of the story still shows up with the %1$s instead of my name.
I've gone over the videos, and cannot figure out where I've deviated from the correct code.
3 Answers
![Mike Sheldon](https://secure.gravatar.com/avatar/c333bd6c6da94de50e4323de5c3d615b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Mike Sheldon
14,897 PointsThis is the code that I have for the pageText
around line 53 of StoryActivity.java
String pageText = mCurrentPage.getText();
// Add the name if placeholder included. Won't add if no placeholder
pageText = String.format(pageText, mName);
mTextView.setText(pageText);
![Alice Spencer](https://secure.gravatar.com/avatar/7b9d27030d643890be6acad25f819655?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Alice Spencer
12,273 PointsYes, I did set the intent. I even took it out and redid it just to make sure I didn't have an error, no luck, but thanks.
![Harley Urquhart](https://uploads.teamtreehouse.com/production/profile-photos/1826822/micro_Hunter.jpg)
Harley Urquhart
26,203 Pointstry cleaning the project if you have done everything right then it might just be AS playing around with you
![Mike Sheldon](https://secure.gravatar.com/avatar/c333bd6c6da94de50e4323de5c3d615b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Mike Sheldon
14,897 PointsI was having the same issue and noticed that "pageText" was grayed out in my code with gray squiggly lines under it and a warning that said:
"The value String.format(pageText, mName) assigned to 'pageText' is never used"
This was in the line: ``` pageText = String.format(pageText, mName);
Looking through my code I found that the next line below that was incorrect.
Here is what I had: ```
mTextView.setText(page.getText());
And here is what it needed to be: ``` mTextView.setText(pageText);
This replacement happened about 25 seconds into the video and I had missed it and this is what was breaking it for me.
![Alice Spencer](https://secure.gravatar.com/avatar/7b9d27030d643890be6acad25f819655?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Alice Spencer
12,273 PointsThat doesn't seem to be it either. This is what I've got in StoryActivity
//Add the name if placeholder included. Won't add if no placeholder
String pageText = mCurrentPage.getText();
mTextView.setText(mCurrentPage.getText());
I tried replacing those to lines, and got errors.
![Ruggiero A](https://secure.gravatar.com/avatar/425eda5308eefd06ba9f763879fc4f4f?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ruggiero A
8,534 PointsAlice Spencer it can seem a silly mistake but.. did you set your mNameField correctly?
mNameField = (EditText) findViewById(R.id.editText);
Ruggiero A
8,534 PointsRuggiero A
8,534 PointsDid you actually set the intent in the StoryActivity.java file?
Intent intent = getIntent();