在活动之间传递文字 [英] Pass Text Between Activities
问题描述
可能重复:
在Android中的活动之间传递数据
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?
推荐答案
您可以先在意图上使用intent.putExtra("key", text_field.getText().toString())
通过意图传递额外的数据,然后再发送意图(在第一个活动中)和getIntent().getExtras().getString("key")
在第二个活动中.
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.
这假设text_field
是您要从中传递值的EditText
.您也可以将"key"
更改为所需的任何内容.
This is assuming text_field
is your EditText
you want to pass the value from. You can change "key"
to whatever you want, too.
这篇关于在活动之间传递文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!