Activity间用Intent和Bundle传递参数
2015-03-27 17:13
309 查看
传递方:
//点击btn_sub传递 fieldHeight.getText()和 fieldWeight.getText()
private void setListeners()
{
btn_sub.setOnClickListener(calrBMI);
}
private OnClickListener calrBMI = new OnClickListener()
{
public void onClick(View v)
{
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("key_height", fieldHeight.getText().toString());
bundle.putString("key_weight", fieldWeight.getText().toString());
intent.setClass(ActivityMain.this,Report.class);
intent.putExtras(bundle);
startActivity(intent);
}
};
接收方:
Bundle bundle = new Bundle();
bundle = this.getIntent().getExtras();
double height = Double.parseDouble(bundle.getString("key_height"))/100;
double weight = Double.parseDouble(bundle.getString("key_weight"));
相关文章推荐
- Activity和Fragment用Intent和Bundle传递参数--总结
- Activity间用Intent和Bundle传递参数
- Activity间用Intent和Bundle传递参数
- Activity间用Intent和Bundle传递参数
- Activity间用Intent和Bundle传递参数
- android中传递复杂参数,activity之间和fragment之间的bundle传递集合/对象
- Android中Activity之间的数据传递(Intent和Bundle)
- Android Bundle的使用及与Intent传递参数区别
- Android开发系列(十三):Intent实现Activity之间的转换以及startActivityForResult传递参数
- android中传递复杂参数,activity之间和fragment之间的bundle传递集合/对象
- android学习笔记(一)activity的基本用法和创建,bundle如何传递数据,intent的用法
- Android中Activity之间的数据传递(Intent和Bundle)
- Activity 间 bundle 传递参数
- Activity中使用Intent实现页面跳转与参数的传递
- Activity中使用Intent实现页面跳转与参数的传递(转)
- Android,使用Intent或Bundle传递参数,跳转页面。
- 使用Intent来启动Activity并传递参数
- [Android] 以singleInstance模式加载的Activity怎么接收以Bundle方式传递过来的参数 By onNewIntent() but not onResum
- Android——通过Intent,Bundle在activity间进行数据传递
- 在 Activity 之间传递(Bundle)参数