2011-06-07 14 views
3

我在一个活动中有这个EditText字段,并且我想要它,所以当我单击附加到该字段的按钮时,该字段被拉到另一个活动中的另一个文本字段中。我真的不知道从这开始。有什么建议么?将编辑文本中的信息提取到另一个活动?

感谢您的帮助。

回答

5

里面ActivityA,当你想开始另一个活动,你这样做:

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); 

和ActivityB的onCreate(),你这样做

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

的伟大工程。感谢您的答复。 – Christian 2011-06-07 18:41:07

相关问题