用Intent传递对数,发送参数的页面如下
1 public void onClick(View v) { 2 Intent intent=new Intent(MainActivity.this, SecondActivity.class); 3 intent.putExtra("extra_data","Hello world"); 4 intent.putExtra("age",15); 5 startActivity(intent);
接收对数的页面如下:
Intent intent=getIntent(); String a=intent.getStringExtra("extra_data"); Log.d("SecondActivity",a);