一、传递一个数据类型
传送值:
Intent intent = new Intent(Login_Activity.this, Sign_Activity.class);
intent.putExtra("name", userName);
intent.putExtra("password", password);
intent.putExtra("ipAddress", "172.31.71.151");
接收:
Intent intent=getIntent();
this.patrolName = intent.getStringExtra("name");
this.patrolPassword = intent.getStringExtra("password");
this.ipAddress = intent.getStringExtra("ipAddress");
二、传递一个对象
Item item = (Item) adapter.getItem(position); //要传递的对象。注意这个对象必须滴被序列化的 对象
Intent intent = new Intent(ListViewDemo01Activity.this,DetailActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("item", item);
intent.putExtras(bundle);
startActivity(intent);
接收方:
Item item = (Item) getIntent().getSerializableExtra("item");