Posted on 2016-10-26 00:54
leekiang 阅读(257)
评论(0) 编辑 收藏 所属分类:
android
向下一个Activity传递数据(使用Bundle和Intent.putExtras)
Intent it = new Intent(Activity.Main.this, Activity2.class);
Bundle bundle=new Bundle();
bundle.putString("name", "This is from MainActivity!");
it.putExtras(bundle); // it.putExtra("name","abc");
startActivity(it); // startActivityForResult(it,REQUEST_CODE);
对于数据的获取可以采用:
Bundle bundle=getIntent().getExtras();
String name=bundle.getString("name");
参考:
http://www.cnblogs.com/feisky/archive/2010/01/16/1649081.html
http://www.cnblogs.com/tornadomeet/archive/2012/07/28/2613617.html 从一个activity跳转到另外一个activity