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!
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

Michael Singleton
6,253 Pointsadding a new screen to app
I would like to create my text as a link to another screen(page) on the app. How do I do that?
4 Answers

Omar Tsai
1,704 Pointssomething like this
public class MyActivity extends Activity {
private EditText mNameField;
private Button mStartButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
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();
//Toast.makeText(MyActivity.this,"Name created",Toast.LENGTH_LONG).show();
startStory(name);
}
});
}
In this first we had a Button in the layout then we made a button variable, next we initialized the button using the mStartButton = (Button)findViewById(R.id.StartButton); and then made a onclicklistener for the button.

Albert Evangelista
27,682 Pointsits like adding a button on the screen but instead of a button you put a TextView on the screen and then you make the onClickListener for the TextView and in that listener you launch an activity using startActivity.

Michael Singleton
6,253 Pointshow do you create an onClickListener?

Omar Tsai
1,704 PointsPretty much you make a onclicklistener for the textview which directs you to a new layout.

Michael Singleton
6,253 Pointshow do you create an onClickListener?