您的位置:首页 > 其它

传递数据包

2015-12-14 20:15 274 查看
设置参数

Intent i = new Intent(MainActivity.this,TheAty.class);
Bundle bundle = new Bundle();
bundle.putString("name", "王城");
bundle.putInt("age", 26);
i.putExtras(bundle);//i.putExtra("data", bundle);
startActivity(i);

接收数据包

TextView tv = (TextView) findViewById(R.id.otherActy);
Intent i = getIntent();
Bundle data = i.getExtras();//Bundle data = i.getBundleExtra("data");

tv.setText(String.format("%s的年龄是%d",data.getString("name"),data.getInt("age")));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: