Christian
Christian

Reputation: 942

Pulling info from edit text to another activity?

I have this EditText field inside of one activity, and I want it so when I click the button attached to this field, the field gets pulled into another text field in a different activity. I am not really sure were to start on this. Any suggestions?

Thanks for the help.

Upvotes: 3

Views: 1880

Answers (1)

ferostar
ferostar

Reputation: 7082

Inside ActivityA, when you wish to start another activity, you do:

Intent intent = new Intent(this, Activity.B);
// pass the content of your EditText as parameter to the intent you use to start the other activity
intent.putExtra("string", editText.getText().toString(); 
startActivity(intent);

and in ActivityB's onCreate() you do something like

// retrieve the text and show it in the TextView
textView.setText(getIntent().getExtras().getString("string")); 

Upvotes: 5

Related Questions