Start a Activity by send extra message

//define this at the top of the first Activity
public final static String EXTRA_MESSAGE="com.binni.AndroidUI.MESSAGE";

//first Activity
Intent intent =new Intent(this,DisplayMessageActivity.class);
EditText edittext=(EditText)findViewById(R.id.edit_message);
String str=edittext.getText().toString();
intent.putExtra(EXTRA_MESSAGE, str);
startActivity(intent);


//second Activity
Intent intent=getIntent();
String str= intent.getStringExtra(AndroidUIActivity.EXTRA_MESSAGE);
TextView textview=(TextView)findViewById(R.id.textview);
textview.setText(str);

  

posted @ 2012-09-13 21:34  niky  阅读(585)  评论(0编辑  收藏  举报