Activity之间传递参数

发送
intent.setClass(Bmi.this, Report.class);
Bundle bundle = new Bundle();
bundle.putString("KEY_HEIGHT", field_height.getText().toString());
bundle.putString("KEY_WEIGHT", field_weight.getText().toString());
intent.putExtras(bundle);
startActivity(intent);
接收解析
Bundle bunde = this.getIntent().getExtras();
double height = Double.parseDouble(bunde.getString("KEY_HEIGHT"))/100;
double weight = Double.parseDouble(bunde.getString("KEY_WEIGHT"));

也可以不透过 Bundle 交换信息
intent.setString发送
this.getIntent().getString接收

posted @ 2011-09-17 09:37  jetz  阅读(249)  评论(0编辑  收藏  举报