为什么这行不通?只是试图将可编辑的字符串从一个活动传递到另一个活动。但我无法让它工作。通过意图传递的字符串是否必须预先定义?如果是这样,我该如何传递可编辑的字符串?
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
textOut.setText(textIn.getText());
Intent intent = new Intent(TutorialOne.this,MainActivity.class);
intent.putExtra("text", textIn.getText());
startActivity(intent);
}
public class MainActivity extends Activity
{
TextView gettext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gettext = (TextView) findViewById(R.id.textView1);
Intent intent = getIntent();
intent.getExtras().getString("text");
String s = intent.getStringExtra("text");
gettext.setText(s);
gettext.setTextColor(Color.WHITE);
}