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
Terence Evans
1,870 PointsIn "Build An Interactive Story" In the "Adding a 2nd Activity" the Action button does nothing for me.
In "Build An Interactive Story" In the "Adding a 2nd Activity" the Action button does nothing for me. I have tried to follow what was showing in the video lesson. Maybe it stems back to my unresolved problem in my MainActivity where the mStartButton is highlighted in orange ie. private Button mStartButton; When I hover over it i get a message about the field can be converted to local variable. I also note that the last message in my logcat is: eglSurfaceAttrib not implemented
2 Answers
Terence Evans
1,870 PointsI did in my most recent post, but here goes again: package com.example.twesq.interactivestory;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
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);
}
}
Thanks
Terence Evans
1,870 PointsI was asked to check a "best answer", but can't because I am still stuck with my problem. Is there anybody who can help me with my problem?
Daniel Hartin
18,106 PointsHi Terence
Your code looks fine to me. It should start the storyActivity class. Other things to consider are have you got the correct id for the button? Does the storyActivity exist? And is the storyActivity defined as an activity in the manifest?
Terence Evans
1,870 PointsThanks Daniel. I have been so discouraged that I haven't looked at this in almost 2 weeks.
- I don't know if I have the correct ID for the button. How can I tell this?
- I do have a tab with a little light-blue dot with a "c" in it that is titled "Story Activity.java"
- I don't know if the storyActivity is defined as an activity in the manifest. How can I check this?
Daniel Hartin
18,106 PointsDaniel Hartin
18,106 PointsHi Terence
Any chance you could post your code here please, it's hard to see what the problem is without it. Hopefully we can come up with a solution then.
Thanks Daniel