从源 Activity 中传递数据
Intent intent=new Intent(); //建立一个Intent
Bundle bundle=new Bundle(); //建立一个Bundle
bundle.putString("key_1","这是一"); //向Bundle中放入参数值
bundle.putString("key_2","这是二"); //向Bundle中放入参数值
intent.putExtras(bundle); //把Bundle附加到Intent中
intent.setClass(MainActivity.this,newactivity.class); //利用setClass跳到newactivity中
startActivity(intent);
目标 Activity 中获取数据
Bundle bundle =this.getIntent().getExtras(); //建立一个Bundle 从获取Intent中的附加中建立Bundle
edittext.setText(bundle.getString("key_1")); //设置编辑文本框的值是bundle第一个参数值
setContentView(edittext); //呈现出来