第一个活动 -
Button btn = (Button)findViewById(R.id.button1);
b.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String passingdata = textview.getText().toString();
Intent i = new Intent(Activity1.this, Activity2.class);
Bundle b = new Bundle();
b.putString("Key", passingdata);
i.putExtras(b);
startActivity(i);
}
});
第二个活动——
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
Bundle b = getIntent().getExtras();
String receivingdata = b.getStringExtra("Key");
TextView tv = (TextView)findViewById(R.id.secondtext);
tv.setText(receivingdata);
}