Pass Text Between Activities [duplicate]

2019-01-27 04:57发布

问题:

Possible Duplicate:
Passing data between activities in Android

How can I edit text in my Activity, then pass this text by an intent to a new Activity?

回答1:

You can pass extra data via the intent using intent.putExtra("key", text_field.getText().toString()) on the intent before you send it (in the first activity) and getIntent().getExtras().getString("key") in the second activity.

This is assuming text_field is your EditText you want to pass the value from. You can change "key" to whatever you want, too.