设置参数
Intent i = new Intent(MainActivity.this,TheAty.class);
Bundle bundle = new Bundle();
bundle.putString("name", "王城");
bundle.putInt("age", 26);
i.putExtras(bundle);
startActivity(i);
接收数据包
TextView tv = (TextView) findViewById(R.id.otherActy);
Intent i = getIntent();
Bundle data = i.getExtras();
tv.setText(String.format("%s的年龄是%d",data.getString("name"),data.getInt("age")));
时间: 2024-10-13 11:32:18