android页面跳转实现
解决方法:
1、MainActivity的代码:
//将数据存到Bundle
Bundle bundle = new Bundle();
bundle.putBoolean("sex", true);
bundle.putInt("height", 165);
//实例化Intent,MainActivity指当前的Activiti名字,ResultActivity是要跳到的Activitiy,就是说from MainActivity to ResultActivity跳转的过程。
Intent intent = new Intent(MainActivity.this,ResultActivity.class);
intent.putExtras(bundle);//把数据通过Intent传到下一个Activitiy显示
startActivity(intent);
2、ResultActivity的代码:
//得到Intent
Intent intent = getIntent();
//取出Bundle
Bundle bundle = intent.getExtras();
//得到性别和身高
boolean sex = bundle.getBoolean("sex",false);
int height = bundle.getInt("height",170);
本文地址:http://www.yayihouse.com/yayishuwu/chapter/1154